我有下表:
table_a
id | charge
1 | 95
1 | 1
2 | 25
我想从每个ID中选择最低的费用,并确定其是否小于...例如
SELECT ID,从FROM TABLE_A收取费用(最低)> 10 GROUP BY ID
Results:
None
SELECT id,charge from table_a WHERE MIN(charge)
Results:
id | charge
1 | 1
最佳答案
您要使用having
子句:
SELECT id, min(charge)
FROM table_a
group by id
having MIN(charge) < 10