with tem as(SELECT t.a,t.b,sum(t.c) FROM tablename tWHERE t.d = 3GROUP by t.a,t.b)SELECT * from tem这个'where t.d = 3'条件怎么能放到括号外面查询
with tem as (SELECT t.a,t.b,t.d,sum(t.c) FROM tablename t GROUP by t.a,t.b,t.d) SELECT * from tem where d=3
你select 的字段是t.a,t.b,sum(t.c) 这三个,就等于你的tem表只有这三个字段。
t.d不在这三个字段里面,肯定放不到外面啊。
with tem as(SELECT t.a,t.b,sum(t.c) FROM tablename tGROUP by t.a,t.b)SELECT * from tem
WHERE tem.d = 3