Sql语句获取数据前几条,后几条

1.获取数据前10条 SELECT TOP 子句

select top 条数 * from 表名
select top 10 * from table_1

2.获取数据后10条

select top 条数 * from 表名 order by index desc   --根据index降序
select top 10 * from table_1 order by index desc

3.获取数据前百分之20 SELECT TOP PERCENT

select top 百分比 percent * from 表名
select top 20 percent * from table_1

4.获取数据后百分之20

select top 百分比 percent * from 表名 order by index desc   --根据index降序
select top 20 percent * from table_1 by index desc
posted @ 2021-01-07 10:30  倔强的烤马铃薯  阅读(35)  评论(0)    收藏  举报  来源