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')

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM