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

Aggregating Derived amounts in Access 1

Status
Not open for further replies.

memkam

Technical User
Aug 3, 2004
40
US
Hello all,

I have a table with some IDs. A group of IDs is 777 and the rest are all different. Each ID has an associated amount with it. I want to generate the sum of amounts for all IDs with 777 and all the other IDs. So, I would end up with 2 aggregate amounts -
SUM of IDs 777
SUM of IDs not 777

Select iif(T.ID = 777,SUM(T.AMount),0) AS [SUm of 777], iif(T.ID <> 777,SUM(T.AMount),0) AS [SUm of Not 777]
From TransactionReport T

I haven't been able to run the query because it states - amount is not an aggregate function. I know it can be added, but its just messing up somewhere.

Thanks for reading!

 

Select SUM(iif(T.ID = 777,T.AMount,0)) AS [SUm of 777],
SUM(iif(T.ID <> 777,T.AMount,0)) AS [SUm of Not 777]
From TransactionReport T
 
Thanks cmmrfrds, appreciate the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top