比如这条sql语句:
sc表是这样的:
s# c# g
1 1 100
1 2 50
1 3 55
2 1 100
2 2 77
2 3 55
3 1 66
3 2 78
3 3 99
3 4 77
3 5 89
4 2 55
4 1 22
4 3 69
4 5 57sql语句是:SELECT [s#] from sc where [s#]>1   GROUP BY [S#]我想问的是,执行where过滤的时候是不是先得到>1的所有行,再进行group by 分组,是吗?问题好像有点傻,得个确认

解决方案 »

  1.   

    Ctrl+ L 看执行计划! 先查找,再聚合!
      

  2.   

    if object_id('tb') is not null
    drop table tb
    go
    create table tb(id int identity(1,1), name varchar(20))
    insert into tb(name)
    select 'z' union all
    select 'z' union all
    select 'y' union all
    select 'y' union all
    select 'y' union all
    select 'w' union all
    select 'w' union all
    select 'w' select name from tb where id>2 group by nameCtrl+ L 看执行计划!