请教SQL语句写法(50分)

  • 主题发起人 主题发起人 心心
  • 开始时间 开始时间

心心

Unregistered / Unconfirmed
GUEST, unregistred user!
A表
DM MC
01 AAA
02 BBB
....


B表
DM MC1 MC2 MC3
01 0.1 22.5 33
02 0.2 333 44
01 0.3 0.5 0.5
02 3 3 3
....

统计名称为BBB的MC1,MC2,MC3的个数,总计的SQL如何写?
 
select count(*),sum(mc1),sum(mc2),sum(mc3) from b
where dm in (select dm from a where mc='BBB')
 
DM.Data_Query1.SQL.Add(
'select D02,Count(D02),Sum(X14),Sum(X11) from ' +
Data_Month +
' Where D03 in(select dm from DWDM where dm=' + '''' + '01' + '''' + ')' +
' group by ' + 'D02');
写好了,谢谢PIPI
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
599
import
I
后退
顶部