Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/67.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql 按最小值和最大值选择id(sql)_Mysql_Sql_Select_Max_Min - Fatal编程技术网

Mysql 按最小值和最大值选择id(sql)

Mysql 按最小值和最大值选择id(sql),mysql,sql,select,max,min,Mysql,Sql,Select,Max,Min,列出折扣最大的客户的id和折扣百分比 以及折扣最小的id。您可以使用MAX()和MIN()函数获取折扣最大的id和折扣最小的id Select id,discount from customer where discount=(select MAX(discount) from customer) OR discount=(select MIN(discount) from customer); 你能试着更详细地解释一下你想要达到的目标吗?你的桌子是什么样子的(可以举一个小例子)?现在很难理

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

以及折扣最小的id。

您可以使用MAX()和MIN()函数获取折扣最大的id和折扣最小的id

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

你能试着更详细地解释一下你想要达到的目标吗?你的桌子是什么样子的(可以举一个小例子)?现在很难理解您的要求。对不起,非常感谢您的回答,但是您忘记了选择折扣,因为上面写着列表id和折扣。您必须知道这件小事。此外,如果你不能投票支持我的answar,你就不应该投票反对这个愚蠢的计划mistake@hadel...thanksI真的很抱歉,这是我第一次来这里,我错了,我不知道这是什么,因为我以为这是为了上下。再次抱歉