日期:2014-05-17 浏览次数:20564 次
select MONTH(a.SummaryDate) as Date,--每个月
SUM(a.RevenueMoney) as AllMoney--每个月的收入
FROM dbo.Summary AS a
WHERE YEAR(a.SummaryDate)='2012' and --?这里假设你要查?2010年的每月的统计。
a.SId = '001'
GROUP BY
MONTH (a.SummaryDate)
order by (Date) desc
select MONTH(a.SummaryDate) as Date,--每个月
SUM(a.RevenueMoney) as AllMoney--每个月的收入
FROM dbo.Summary_1 AS a
WHERE YEAR(a.SummaryDate)='2012' and --?这里假设你要查?2010年的每月的统计。
a.SId = '001'
GROUP BY
MONTH (a.SummaryDate)
order by (Date) desc
select MONTH(a.SummaryDate) as Date,--每个月
SUM(a.RevenueMoney) as AllMoney--每个月的收入
FROM dbo.Summary_2 AS a
WHERE YEAR(a.SummaryDate)='2012' and --?这里假设你要查?2010年的每月的统计。
a.SId = '001'
GROUP BY
MONTH (a.SummaryDate)
order by (Date) desc
select MONTH(a.SummaryDate) as Date,
SUM(a.RevenueMoney) as AllMoney
FROM (select summarydate,revenueMoney from dbo.Summary
WHERE YEAR(a.SummaryDate)='2012' and
a.SId = '001' union all
select summarydate,revenueMoney from dbo.summary_1
WHERE YEAR(a.SummaryDate)='2012' and
a.SId = '001' union all
select summarydate,revenueMoney from dbo.summary_2
WHERE YEAR(a.SummaryDate)='2012' and
a.SId = '001')
AS a
GROUP BY
MONTH (a.SummaryDate)
order by (Date) desc