Access数据库SQL查询(300分)

  • 主题发起人 主题发起人 myhby
  • 开始时间 开始时间
M

myhby

Unregistered / Unconfirmed
GUEST, unregistred user!
表:aaaa
字段:FName //名称
FDate //日期
je //金额

要求:按FName分类对Je汇总如下表
名称,合计金额,1月份合计金额,...,12月份合计金额
 
select FName,
Yearn,
(select sum(je)
from aaaa A1
where A1.FName = G.FName
and Year(A1.FDate) = G.Yearn ) as 全年合计,
(select sum(je)
from aaaa A1
where A1.FName = G.FName
and Year(A1.FDate) = G.Yearn
and Month(A1.FDate) = 1) as 1月,
(select sum(je)
from aaaa A1
where A1.FName = G.FName
and Year(A1.FDate) = G.Yearn
and Month(A1.FDate) = 2) as 2月,
...
from (select distinct FName, Year(FDate) Yearn from aaaa) G
 
高手,谢谢!
 
后退
顶部