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
 SQL Server 2012 Forums
 Transact-SQL (2012)
 more than 5 column with total

Author  Topic 

usafelix
Posting Yak Master

165 Posts

Posted - 2014-08-22 : 15:27:54
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 ?



James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2014-08-22 : 16:27:35
quote:
Originally posted by usafelix

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 ?





In simple queries, SQL Server can output only tabular data - i.e., every row will have the same number of columns, and every column would have the same type of data. The output you want does not appear to be such tabular data.

To produce reports such as what you are looking for a reporting tool (SQL Reporting Services, Crystal Reports etc.) are more suitable.
Go to Top of Page
   

- Advertisement -