select查詢的執行順序

一些不知道爲什麼執行出錯的SQl語句,往往是因爲你不瞭解他的執行順序。

Select distinct top n [percent] 列名

from 表名

where 條件

group by ... having ...

order by ... asc/desc


執行順序

1>...from 表

2>...where 條件

3>...group by    列

4>...having 篩選條件

5>...Select >選擇列 >distinct

6>...order by 列

7>...Top(最後計算)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章