SQL SERVER 子查询使用Order By;按In排序

时间:2022-10-05 00:24:50

【子查询】使用order by

select * fromselect top 100 percent * from table order by id) a

这时发现结果没有按id排序,需要将100 percent 改成 99.999 percent 或10000000(尽量大)

select * fromselect top 99.999 percent * from table order by id) a

select * fromselect top 1000000 * from table order by id) a

【排序】 按in里内容排序

select * from table where id in ('xxxx') order by charindex(id,'xxxx')