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