eliza81 Posted February 9, 2010 Share Posted February 9, 2010 Hi all, I am sharing a tip with you.Any suggestions are appreciated.And everyone is welcomed to add to this discussion.Suppose we have a Sales table having SalesId, ContactId and SalesTotal. If we need a summary report, which will display total SalesTotal group by its ContactId.This can be done using a simple query:SELECT IFNULL(`ContactId` , "GRAND TOTAL") AS 'CONTACT ID', SUM(`SalesTotal`) AS `TOTAL` FROM Sales GROUP BY `ContactId` WITH ROLLUPOutput:CONTACT ID TOTAL 117 5118 0119 10GRAND TOTAL 15You can't use the ORDER BY clause with the WITH ROLLUP. They are mutually exclusive. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.