d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Sql Q
Add Reply New Topic New Poll
Member
Posts: 1,849
Joined: May 31 2008
Gold: 2,571.50
Dec 12 2014 04:26pm
Code


SELECT BK.CATEGORY, NVL(BK.TITLE,'===Sum of category===') AS TITLE,
NVL(TO_CHAR(SUM(OI.PAIDEACH),'$9999.99'),'-none-') AS SALES,
NVL(SUM(OI.QUANTITY),0) AS QTY
FROM books bk LEFT OUTER JOIN orderitems oi
ON (bk.isbn = oi.isbn)
GROUP BY CATEGORY, ROLLUP(title)
ORDER BY CATEGORY;



Hopefully this makes sense - but looking to have at the bottom of the results display a 'grand total' of sales as well as 'grand total' of qty of books sold

I was able to get all the data besides that to show -- not sure how -- what am i missing?
Member
Posts: 1,849
Joined: May 31 2008
Gold: 2,571.50
Dec 12 2014 05:10pm
Quote (Noobtard @ Dec 12 2014 05:26pm)
Code
SELECT BK.CATEGORY, NVL(BK.TITLE,'===Sum of category===') AS TITLE,
      NVL(TO_CHAR(SUM(OI.PAIDEACH),'$9999.99'),'-none-') AS SALES,
      NVL(SUM(OI.QUANTITY),0) AS QTY
FROM books bk LEFT OUTER JOIN orderitems oi
ON (bk.isbn = oi.isbn)
GROUP BY CATEGORY, ROLLUP(title)
ORDER BY CATEGORY;


Hopefully this makes sense - but looking to have at the bottom of the results display a 'grand total' of sales as well as 'grand total' of qty of books sold

I was able to get all the data besides that to show -- not sure how -- what am i missing?


oohh, i understand rollup better now...

I needed to have Rollup(category,title)

herp
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll