2011-05-20 38 views
0

我昨晚讀了關於使用sql MIN(),我明白它現在的工作原理。然而,我想知道,我如何運行從表中選擇多個「ID」的「最低值」

SELECT MIN(card_price) 
FROM card_lookup_values 

並顯示每個單獨卡的最低「價格」。許多卡在card_price列中有5-9個價格。我想我一直在尋找:

card_id card_price 
    0001  2 
    0002  99 
    0003  22.3 
+0

'GROUP BY card_name'是我最好的猜測。 – 2011-05-20 13:19:28

回答

1

您需要一個group by card_name

考慮集合函數閱讀本教程:

http://www.postgresql.org/docs/9.0/static/tutorial-agg.html

+0

謝謝丹尼斯。我從來不知道去哪裏瞭解mysql。 – 2011-05-20 13:30:01

+0

在這種情況下,請嘗試PostgreSQL文檔。他們是imho最好的。 – 2011-05-20 13:34:14