出个SQL语句执行顺序的题目 select [distinct] [top n] [into 新表名称] from 表1 [inner | left | right] join 表2 on <表join的条件> [where <过滤条件>] [group by <分组语法>] [with {cube | rollup}] [having <过滤条件>] [order by <排序列表> [asc | desc ] ] 注意点: 1、distinct、order by、top三者的执行顺序如何?
先order by ,再distinct ,再top
对么。
错了
现实top,再是order by 然后是distinct,因为如果有建立索引的话,应该是先做索引的,所以应该order by 在distinct前吧
错了,再想想他们各自的作用。
先是distinct,然后top, 最后order by
呵呵 还是错了,答案就是文章中的顺序
对噢,是错了。我把top当聚合函数了。