New to Access select statement (1 Viewer)

cataylor

New member
Local time
Today, 13:01
Joined
Apr 18, 2012
Messages
2
Select
Sum([LLR Data].Miles) AS Ttl_Miles, Sum([LLR Data].[Direct Weight]) AS Ttl_Weight,
IIF([LLR Data].[Direct Weight] > 0,[LLR Data].[Miles],0)
where [LLR Data].[Commodity] = 'RETL'





Why can't I use the iff in the select I need to capture the miles depending on the field
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 11:01
Joined
Aug 30, 2003
Messages
36,133
What error do you get? Looks okay offhand. Have you tried summing that field too? I suspect you're running into the error about aggregate functions.
 

cataylor

New member
Local time
Today, 13:01
Joined
Apr 18, 2012
Messages
2
Yes, an aggregate functions error.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 11:01
Joined
Aug 30, 2003
Messages
36,133
Did you try adding the sum?

Select
Sum([LLR Data].Miles) AS Ttl_Miles, Sum([LLR Data].[Direct Weight]) AS Ttl_Weight,
Suum(IIF([LLR Data].[Direct Weight] > 0,[LLR Data].[Miles],0)) As Whatever
where [LLR Data].[Commodity] = 'RETL'
 

Users who are viewing this thread

Top Bottom