[Top] [All Lists]

Query Help

Subject: Query Help
From: "2onboard"
Date: Wed, 8 Aug 2007 17:58:10 +0000 UTC
Newsgroups: macromedia.coldfusion.cfml_general_discussion
Here is my query as it stands right now
 variable useYear is set to now()

 SELECT riderId, Month(rideDate) AS rideMonth, rideDistance
 SUM(CASE WHEN Month(rideDate)='1' AND Year(rideDate)='Year(useYear)'
        THEN rideDistance
        ELSE 0) AS jan
 FROM mileageLog
 GROUP BY riderId, Month(rideDate)
 ORDER By riderId, Month(rideDate)

 I am attempting to find the sum per riderId for each month (only January is 
shown above right now) if there is no data for a riderId in January, then set 
to 0

 currently I get
 Syntax error (missing operator) in query expression 'rideDistance SUM(CASE 
WHEN rideMonth='1' THEN rideDistance ELSE 0)'. 


<Prev in Thread] Current Thread [Next in Thread>