通过min和max选择id(sql)

时间:2015-11-28 14:32:28

标签: mysql sql select max min

列出折扣最大的客户的ID和折扣百分比

和那些折扣最小的人。

1 个答案:

答案 0 :(得分:0)

您可以使用MAX()和MIN()函数来获取具有最大值且ID具有最小折扣的ID。

Select id,discount
from customer 
where discount=(select MAX(discount) from customer) OR discount=(select MIN(discount) from customer);