www.7671.net > sql语句查询最小值

sql语句查询最小值

答案如下:SELECT TOP 1 year,month FROM [你的表名] ORDER BY ver,year,month 分析的思路:从题目上看,要求查询的ver year month都要求是查询最小值,那么我们能想到查询最小值的方法有很多,其中最简便的一种思路就是从小到大排

利用函数查询即可啊 假设查询SAL(薪金)列的最小值 select min(sal) from table_name;

先用order by排序,然后前面加上top 1

select max(t) as 温度最大值,min(t) as 温度最小值,max(p) as 湿度最大值,min(p) as 湿度最小值,max(datetime) as 最后出现时间,min(datetime) as 最早出现时间 from yourtable_name

1.--大于32313133353236313431303231363533e78988e69d8331333337383230等于所有(最大值) select * from Apo_city where city_id >=all (select city_id from Apo_city)--小于等于所有(最小值) select * from Apo_city where city_id <=all (

select 序号,min(值1)as 值1,min(值2) as 值2from tbgroupby 序号!

要id最小的一条,最简单的语句是:select top1 * from table order by id如果一定要使用where条件,那么可以这样写:select * from table where id=(select min(id) from table)

select user_name, min(money),max(money) from table group by user_name

可通过对数据进行排序,再取第一条的方式获取最大值及最小值示例如下:--取最大值,对支付金额倒序排列,再取第一条declare @d decimalselect top 1 @d= payprices from [dbo].[orderbills] order by payprices descselect @d --输出最大值--取最小值,对支付金额顺序排列,再取第一条declare @d decimalselect top 1 @d= payprices from [dbo].[orderbills] order by payprices select @d--输出最小值

$RS.Open ("Select account ,pwd,Sname,area,rolename From Account where (use=0) ORDER BY level limit 1 ")

友情链接:mydy.net | zxwg.net | rpct.net | nczl.net | zdly.net | 网站地图

All rights reserved Powered by www.7671.net

copyright ©right 2010-2021。
www.7671.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com