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

【子查询】使用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')

猜你喜欢

转载自www.cnblogs.com/itsone/p/10242747.html