开发者

Select "lowest value" from table for multiple "ids"

I read up last night on using the sql MIN() and I underst开发者_如何学编程and how it works now. However, I was wondering, how do I run

SELECT MIN(card_price)
FROM card_lookup_values 

and display the lowest "price" for each individual card. A lot of the cards have 5-9 prices in the card_price column. I guess I was looking for:

 card_id   card_price
    0001      2
    0002      99
    0003      22.3


You need a group by card_name.

Consider reading this tutorial on aggregate functions:

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜