Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 total and grand total query ?

Author  Topic 

usafelix
Posting Yak Master

165 Posts

Posted - 2014-08-23 : 07:41:25
date shop sku staff qty amt
0813 13:20 hk book david 2 50
0813 18:20 usa toy mary 1 15
0813 09:15 hk cake ken 3 350
0813 13:40 can toy mak 7 10

i want...
shop sku staff qty amt
0813 0915 hk cake ken 3 350
0813 13:20 hk book david 2 50
total : 5 qty $400
0813 13:40 can toy mak. 7 $ 10
total : 7qty $10
0813 18:20 usa toy mary 1 $10

total : 13 qty
grand total : 420

it is any easy way to write a simple query ?


SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2014-08-23 : 07:46:17
Have a look at Books Online (the SQL Server help file) for
GROUP BY and specifically

GROUP BY GROUPING SETS ((Shop, SKU), ())



Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page
   

- Advertisement -