Query problem

  • Thread starter Thread starter campbellbrian2001
  • Start date Start date
C

campbellbrian2001

Thanks in advance for any help. I have the following query with a
conditional "count" line (counting only if vehicle loss is > $0.00. I'm
getting syntax errors that are throwing me:

SELECT qryTrucks.TagNumber, qryTrucks.Driver,
Count(IIf(qryTrucks.TotalLoss > 0),(qryTrucks.TagNumber)) AS
CountOfTrucks, Sum(qryTrucks.LossAmt) AS SumOfLossAmt,
Sum(qryTrucks.IndemCost) AS SumOfIndemCost, Sum(qryTrucks.TotalLoss) AS
SumOfTotalLoss
FROM qryTrucks
GROUP BY qryTrucks.TagNumber, qryTrucks.Driver
HAVING (((Sum(qryTrucks.LossAmt))>0) AND
((Sum(qryTrucks.TotalLoss))>0));
 
IIf statements have 3 parts: (Evaluation, truepart, falsepart), you only have
two parts...what happens if the TotalLoss < 0? But rather then try to count
using an IIf statement, add another select statement in the count:

Count (SELECT TagNumber FROM qryTrucks WHERE TotalLoss > 0) As CountOfTrucks
 
Count(IIF( there's probably a solution with better logic than
mine.
 
See my reply in your original post...

FYI -- As far as forum etiquette goes, if there is such a thing LOL, it is
frowned upon to enter mulitple posts, especially so close together. :-)
 
Sorry, the last post was an error...

xRoachx said:
See my reply in your original post...

FYI -- As far as forum etiquette goes, if there is such a thing LOL, it is
frowned upon to enter mulitple posts, especially so close together. :-)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top