如何在其父查询中使用子查询的结果?
我的代码看起来像这样。
select (select count(*) from tbl1 group by field) as result1,
(select count(*) from tbl2 group by field) as result2,
(select count(*) from tbl3 group by field) as result3,
result1 + result2 - result3 as total1,
result1 + result2 as total2
from tbl4 ;
有人建议直接添加子查询。
(select count(*)*....) as result1 + (select count(*)*....) as result2
但我认为它不需要我需要,因为我还需要在我的结果中显示/维护 result1 的值。
有没有人可以帮助我,我非常需要解决这个问题,我感谢每一个帮助。
提前致谢。