ZKX's LAB

sql语句降序排列么 sql 升序降序排列

2020-10-06知识17

sql 升序降序排列 降序:SELECT*FROM kc ORDER BY cpbh DESC升序:SELECT*FROM kc ORDER BY cpbh ASC语法:sql可以根据字段进行排序,其中,DESC表示降序,ASC表示升序order by 字段名 DESC;按照字段名降序排序order by 字段名 ASC;按照字段名升序排序实例:一、/*查询学生表中姓名、学号,并以学号降序排序*/select name,StuID from Students_information order by StuID desc/*order by 以什么排序,默认为升序,desc是降序*/二、/*查询学生表中前5名学生的姓名,学号,并以学号升序排列*/select top 5 name,StuID from Students_information order by StuID/*order by 默认为升序*/扩展资料:一、ORDER BY 语句ORDER BY 语句用于根据指定的列对结果集进行排序。ORDER BY 语句默认按照升序对记录进行排序。如果您希望按照降序对记录进行排序,可以使用 DESC 关键字。二、SQL 排序多个字段order by 多个字段,每个字段后面都有排序方式,默认ASC例如:select table a order by a.time1,a.time2 desc,a.time3 asc参考资料:w3school-SQL ORDER BY 子句

sql语句降序排列么 sql 升序降序排列

mssql指定的ID排在最前面,剩余的按照降序排列。sql语句该怎么写呀? SELECT*,1 AS notify FROM A WHERE ID IN(1,2,3…)UNIONSELECT*FROMSELECT*,2 AS notify FROM A ORDER BY ID DESCEXCEPTSELECT*,2 AS notify FROM A WHERE ID IN(1,2,3…)ORDER BY notify试试看这个思路行不

sql语句降序排列么 sql 升序降序排列

sql一条语句来表示前三项升序排序,其他项降序 实现:12354的效果:假设你要的字段为:col_you_want,类型为 intselect col_you_wantfrom mytable aorder bycase when identity(int,1,1)identity(int,1,1)end asc,col_you_want desc

sql语句降序排列么 sql 升序降序排列

#sql排序#select

随机阅读

qrcode
访问手机版