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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help me with a simple query

Status
Not open for further replies.

flac0

Programmer
Oct 31, 2001
22
UY
Table documents
IdDocument
NameDocument
etc

Table documents_items
IdDocument
iditem
price
etc

Table documents_items_tax
IdDocument
IdItem
Tax
etc

For each document i got some items and for each item i got some taxes...

I need to create a query that can sum for each document the total price and total tax but not discriminate by each item and each tax, only the totals for each document

How i can do it...thanks!
 
This should do it:

select NameDocument, sum(price), sum(tax) from documents inner join documents_items on documents_items.IdDocument = documents.IdDocument inner join documents_items_tax on documents_items_tax.IdItem = documents_items.IdItem group by NameDocument

Dave Robinder, MCSD
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top