select id 的最小值和最大值 (sql)

select id by the min and max (sql)

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

以及折扣最小的那些。

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

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