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
 Combined Orders Grand Total?

Author  Topic 

j0nnyd
Starting Member

2 Posts

Posted - 2007-04-20 : 17:09:52
Hi,

Im using Access and have created a query which adds up the grand totals of clients orders. However i want to be able to add up what each client has spent in total over any given time period. Basically in SQL logic terms:

take all order totals from same client and add together order totals to produce a grand client spend total.

Anyone help!?

thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-04-20 : 17:31:45
You will need to use the SUM function along with GROUP BY. If you provided a data example to show what the table looks like and what the output should look like, then we could write a query.

Please note that you have posted in the SQL Server forum, so answers may not work for Access. There is an Access forum here as well.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

j0nnyd
Starting Member

2 Posts

Posted - 2007-04-20 : 17:39:18
here is the current sql statement:

SELECT [Order Total Details].OrderID, [Order Total Details].CompanyName, Sum([Order Total Details].[Grand Total]) AS [SumOfGrand Total], [Order Total Details].CustomerID
FROM [Order Total Details]
GROUP BY [Order Total Details].OrderID, [Order Total Details].CompanyName, [Order Total Details].CustomerID
ORDER BY [Order Total Details].CompanyName, [Order Total Details].CustomerID;
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-04-20 : 17:50:09
Check out the second sentence in my last post.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page
   

- Advertisement -