select sum(a_col) ,sum(b_col) from abc_table 就出了上面的錯(cuò)誤,google后很多人說(shuō)
指定 GROUP BY 時(shí),選擇列表中任一非聚合表達(dá)式內(nèi)的所有列都應(yīng)包含在 GROUP BY 列表中,或者 GROUP BY 表達(dá)式必須與選擇列表表達(dá)式完全匹配。
就是說(shuō)要 select sum(a_col) ,sum(b_col) from abc_table group by a_col。
而
select sum(a_col) ,sum(b_col) from abc_table
union
select sum(a_col) ,sum(b_col) from abc_table 又是正常的。