全站数据
8 4 2 0 5 8 1

SQL里面的排序语句desc和ASC有什么区别

自考小章鱼 | 简单学习,快乐成才!         
问题更新日期:2024-04-24 05:44:57

问题描述

SQL里面的排序语句desc和ASC有什么区别求高手给解答
精选答案
最佳答案

SQL 语句中, asc是指定列按升序排列,desc则是指定列按降序排列。

排序子句语法:order by 列名 asc/desc

1、按列n2的升序排列

select * from tt order by n2 asc;

select * from tt order by n2 desc;

3、复合排序,先按列n1升序排列,再按n2降序排列

select * from tt order by n1 asc,n2 desc;

其他回答

SQL 语句中, asc是指定列按升序排列,desc则是指定列按降序排列。排序子句语法:order by 列名 asc/desc例表格:ttselect * from tt order by n2 asc;2、按列n2的降序排列select * from tt order by n2 desc;3、复合排序,先按列n1升序排列,再按n2降序排列select * from tt order by n1 asc,n2 desc;

随机推荐