获取分组结果集的最小值

时间:2011-09-01 14:47:07

标签: sql

我有一张桌子

id|    date|      shopid|   price|    region_id
1|    10/12/12|    123|      999|       99
2|    10/12/12|    124|      1099|      99
3|    10/12/12|    125|      899|       99

4|    10/12/12|    459|      989|       100
5|    10/12/12|    457|      979|       100
6|    10/12/12|    456|      939|       100

我想找到的是10/12/12每个地区最便宜的价格

1 个答案:

答案 0 :(得分:1)

SELECT MIN(price) AS price, region_id
FROM FOO
WHERE date = '10/12/12' /*Should use ISO format for dates. Highly ambiguous*/
GROUP BY region_id