主题:sql的SUM问题
ImDS
[专家分:0] 发布于 2006-11-17 08:46:00
有两个表,T1有字段C1(char),C2(int),C3(char),T2有字段C1(char),C2(int),C4(char),现在我想用SUM统计T1和T2所有C2字段的总数,按C1分组,即如SUM(T1.C2)+SUM(T2.C2) GROUP BY C1 .请问具体SQL语句应该怎么写?
回复列表 (共2个回复)
沙发
3031213101 [专家分:310] 发布于 2006-11-19 12:57:00
select sum(T1.C2)+sum(T2.C2) as "sum"
from T1,T2
板凳
nj1986 [专家分:0] 发布于 2006-11-21 23:19:00
c1是哪个表里的,是T2的把最后一行的C1改成T2
select sum(T1.C2)+sum(T2.C2) as "sum"
from T1,T2
group by T1.C1
我来回复