通过WorkAround应用于Group之后的位置?

时间:2012-03-14 23:58:30

标签: sql-server-2008 group-by

有没有办法解决在group by语句后无法使用where子句的问题?假设我需要拥有该组,我想说WHERE x LIKE 'y'是否有解决方法?

2 个答案:

答案 0 :(得分:2)

如果要逐个过滤表达式,可以将过滤器放在HAVING子句中。

select first, second, third, sum(something) something_summed
from tablea
group by first, second, third
having first + second < 10

答案 1 :(得分:0)

Select c1,c2,c4
From (
    Select c1,c2,sum(c3) as c4
    From table1
    Group by c1, c2
     ) A
Where A.c1 Like 'yyy'