SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 more than 5 column with total
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

usafelix
Posting Yak Master

Hong Kong
103 Posts

Posted - 08/22/2014 :  15:27:54  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

3742 Posts

Posted - 08/22/2014 :  16:27:35  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000