我有以下查询: -
SELECT
FISCALYEAR,
DATENAME(Month,JVDate) as Month,
ACCOUNTNUMBER,
ACCOUNTDESCRIPTION,
CATEGORY,
POSTINGTYPE,
ORIGNETAMOUNT,
FROM dbo.vw_GLTrialBalancev2010 INNER JOIN
GL00100 ON GL00100.ACTNUMBR_1 = dbo.vw_GLTrialBalancev2010.SEGMENT1 AND GL00100.ACTNUMBR_2 = dbo.vw_GLTrialBalancev2010.SEGMENT2
显示以下结果: -
任何人都可以告诉我一种分组的方法,然后按类别小计。
我希望看到类似下面的内容: -
所有人都非常感谢。
答案 0 :(得分:1)
SELECT
FISCALYEAR,
DATENAME(Month,JVDate) as Month,
ACCOUNTNUMBER,
ACCOUNTDESCRIPTION,
CATEGORY,
POSTINGTYPE,
sum(ORIGNETAMOUNT) as ORIGNETAMOUNT,
FROM dbo.vw_GLTrialBalancev2010
INNER JOIN GL00100
ON GL00100.ACTNUMBR_1 = dbo.vw_GLTrialBalancev2010.SEGMENT1
AND GL00100.ACTNUMBR_2 = dbo.vw_GLTrialBalancev2010.SEGMENT2
group by FISCALYEAR, DATENAME(Month,JVDate) as Month, ACCOUNTNUMBER,
ACCOUNTDESCRIPTION, CATEGORY, POSTINGTYPE