最新消息:本站所有跳转向bbs.ykit.cn的附件将全面停止,附件已转移到https://www.qingsj.com

SQL查询某字段最小值:(不使用min() max())

Mysql 有客 1553浏览
例如数据表中有一列为工资,查询工资最高的,可以这么写语句:
sql server 数据库下的:
select   top   1   工资   from   table1   order   by   工资   desc;

或者:select   top(1)   *  from   table1   order   by   工资   desc;

其他的类似 
select   top   1   with   ties   id,工资   from   table1   order   by   工资   asc
最少
MySql数据库下使用:

select * from stutable order by age asc limit 0,1

转载请注明:有客帮 » SQL查询某字段最小值:(不使用min() max())