使用SQL创建财务报表

使用SQL创建财务报表,sql,Sql,我想使用select报表创建一份财务报告,例如:我的开始月份是2000年4月,结束月份是2001年3月。我该怎么做 SELECT monthList.MonthName ,transcation.id,transaction.amount( SELECT 10 ordby, 'January' MonthName UNION SELECT 11, 'February' UNION SELECT 12, 'March' UNION SELECT 1, 'April' UNION SELEC

我想使用select报表创建一份财务报告,例如:我的开始月份是2000年4月,结束月份是2001年3月。我该怎么做

SELECT  monthList.MonthName ,transcation.id,transaction.amount(
SELECT 10 ordby, 'January' MonthName 
UNION SELECT 11, 'February' 
UNION SELECT 12, 'March'
UNION SELECT 1, 'April' 
UNION SELECT 2,'May'
UNION SELECT 3,'June'
UNION SELECT 4,'July' 
UNION SELECT 5,'August' 
UNION SELECT 6,'September'
UNION SELECT 7,'October' 
UNION SELECT 8,'November' 
UNION SELECT 9,'December') monthList 
left  JOIN (select YEAR(Date) [Year], MONTH(Date) [Month],DATENAME(MONTH,Date) [Month Name],sum(Amount)as amount 
FROM transaction 
where id=2 GROUP BY YEAR(Date), MONTH(Date),DATENAME(MONTH, Date) ) as t on t.[Month Name]=monthList.[Month Name])

可能是
UNION ALL
。请显示架构、示例数据、预期结果和当前结果。现在还不清楚你在问什么……也许是
UNION ALL
。请显示模式、示例数据、预期结果和当前结果。现在还不清楚你在问什么。。。