GROUP BY 子查询

如 select (select sum(t2.id) from table2 t2 ) from table1 t1 group by xxx

那样如果我里面的子查询想加个条件说t2.xxid in t1.id要怎么做?t1的id group by后都不全了

你可以试试
select sum(t2.id) from table1 t1 left join table2 t2 on t2.xxid = t1.id group by t1.xxx追问

不行,我要的不是连接查询是子查询

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答