0
   select
        (select sum(sal)as sal_tp, sum(local_conv) as lc_tp from budget_tp),
        (select sum(sal) from budget_fos_veri) as sal_veri,
        (select sum(sal) from budget_fos_picks)as sal_pick,
        (select sum(sal) from budget_bpo_other)as sal_bpo;

我明白了

ERROR 1241 (21000): Operand should contain 1 column(s).

有什么方法可以完成我的要求吗?该查询实际上是一个示例。我有许多包含多列的表,我想查看所有表的各个列的总和,我只是尝试在第一行一次查看两个我收到此错误,如果我尝试仅检索一列,那么它美好的。

4

1 回答 1

4

每个子查询应返回一个字段。试试你的查询 -

   select
        (select sum(sal) from budget_tp) as sal_tp,
        (select sum(local_conv) from budget_tp) as lc_tp,
        (select sum(sal) from budget_fos_veri) as sal_veri,
        (select sum(sal) from budget_fos_picks)as sal_pick,
        (select sum(sal) from budget_bpo_other)as sal_bpo;

另一个:

   select
        (select concat(sum(sal), ',' ,sum(local_conv)) from budget_tp) as sal_tp_and_lc_tp
        (select sum(local_conv) from budget_tp) as lc_tp,
        ...
于 2012-08-03T07:27:22.180 回答