Mysql查询:单个查询推荐多少sum()?

我有70种不同类型的帐户。而且我正在根据帐户类型获取数据。

这样的查询

$mainData = "SELECT 
          count(*) AS totalRows,sum(pay) as totalPay

          sum(case when account_type = 1 then 1 else 0 end) AS account_1_Total,sum(case when account_type = 1 then pay else 0 end) AS account_1_Pay,sum(case when account_type = 2 then 1 else 0 end) AS account_2_Total,sum(case when account_type = 2 then pay else 0 end) AS account_2_Pay,{all_account_types_here}

          FROM account_table";

最后,这些 sum()大约有140多个。

问题是,在单个查询中推荐多少个 sum()

谢谢!

已编辑

GROUP BY是它的解决方案。

awfvfhpHE 回答:Mysql查询:单个查询推荐多少sum()?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3167024.html

大家都在问