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.
| 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 Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
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].CustomerIDFROM [Order Total Details]GROUP BY [Order Total Details].OrderID, [Order Total Details].CompanyName, [Order Total Details].CustomerIDORDER BY [Order Total Details].CompanyName, [Order Total Details].CustomerID; |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2007-04-20 : 17:50:09
|
| Check out the second sentence in my last post.Tara Kizerhttp://weblogs.sqlteam.com/tarad/ |
 |
|
|
|
|
|