数据库排序

use mydb
--排序
select *from Category  order by Ids asc
--order排序的意思
--asc 升序
select *from Category  order by Ids desc
--desc 降序
select *from Category order by parent,ids
--首先遵循第一排序原则 默认升序
select *from Category order by parent desc,ids desc
--根据先后顺序排列降序
select parent from  Category group by Parent
select code from Category  where Parent ='m'
--group 分组
--distinct去重,去重复显示
select distinct parent from Category
--前多少条数据
select *from Category --查询全部信息
select top 5 *from Category
--查询前5条信息
select top 5 *from Category order by Ids
--排序查询前5条信息
select top 5 *from Category where Ids >900 and Ids <950 order by
--先筛选后排序

原文地址:https://www.cnblogs.com/yangyue/p/4120183.html