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

Sum Function in a Query

Status
Not open for further replies.
Jul 14, 2003
116
CA
I'm am trying to run the following query but I am getting an error:

SELECT TRR.empBUnit, TRR.empDivision, TRR.empDirector, TRR.empGroup,
-Sum(TRR.Status='Completed') AS Completed,
-Sum(TRR.Status='In Progress') AS InProgress
FROM TenRulesSecAdminRAW TRR
GROUP BY TRR.empBUnit, TRR.empDivision, TRR.empDirector, TRR.empGroup, TRR.Statues;

This is the error that I get:
Server: Msg 170, Level 15, State 1, Line 2
Line 2: Incorrect syntax near '='.

I have run this query in an Access
 
How does this work for you?
Code:
SELECT TRR.empBUnit, TRR.empDivision,
    TRR.empDirector, TRR.empGroup,
    -Sum(CASE WHEN TRR.Status='Completed'
              THEN 1 ELSE 0 END
     ) AS Completed, 
    -Sum(CASE WHEN TRR.Status='In Progress'
              THEN 1 ELSE 0 END
     ) AS InProgress
FROM TenRulesSecAdminRAW TRR
GROUP BY TRR.empBUnit, TRR.empDivision,
  TRR.empDirector, TRR.empGroup;

--John [rainbow]
-----------------------------------
Behold! As a wild ass in the desert
go forth I to do my work.
--Gurnie Hallock (Dune)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top