聚合函数和group by例如,我需要在A表里查询B C D 这3列按B来分组,但是要计算C的和select b d sum(c)
from a
group by ????可以实现的吗?刚开始学聚合函数和group by好多东西想不明白但是不知道怎么表达..........求解
from a
group by ????可以实现的吗?刚开始学聚合函数和group by好多东西想不明白但是不知道怎么表达..........求解
from a
group by b,d
from t
group by b
insert into a
select 'q',5,'asd' union all
select 'q',6,'qwe' union all
select 'w',7,'ert' union all
select 'e',8,'tgb' select B, sum(C) as C
from a
group by B
B C
---- -----------
e 8
q 11
w 7(3 row(s) affected)如果按你的要求的话,D是检索不出来的
from A
group by B
select B,Max(d) as d,sum(C) as c
from A
group by B