0

I have the below query:-

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

That displays the below results:-

enter image description here

Can anyone show me a way to group and then subtotal by Category.

I would like to see something like the below:-

enter image description here

All help greatly appreciated.

4

1 回答 1

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
于 2013-06-12T15:01:51.267 回答