Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Group totals in SQL XML Query (SQL2008)

Status
Not open for further replies.

CarolCook

IS-IT--Management
Mar 7, 2003
158
US
Hi:
I need to create a simple query whose output is XML. It needs to print invoices with amounts for each customer but also needs to pass the total invoice amount for each customer. (I am using InfoPath to create the XSL which is then used by an end-user product which apparently does not support any totals created witin InfoPath.)

XML does not allow COMPUTE SUM but that is what I am trying to emulate.

The output of the query would ideally be:

cust A
invoice 1 xxx.xx custA total
invoice 2 yyy.yy custA total
cust b
inv 1 aaa.aa custb total
etc.

where custA total is essentially the same number on each line. Possible?
thanks in advance
 
You might want to try ROLLUP. Check BOL under group by.
Also you might want to use pivot tables.



Ordinary Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top