Mar 12, 2009 #1 SMAlvarez Programmer Dec 4, 2005 27 US As for I know this is a valid sql statement, but for some reason access gives me a syntax error. How can I fix it? Thanks. SELECT SUM(CASE WHEN City = 'Sandnes' THEN 1 ELSE 0 END) as FieldNeeded1 FROM Persons;
As for I know this is a valid sql statement, but for some reason access gives me a syntax error. How can I fix it? Thanks. SELECT SUM(CASE WHEN City = 'Sandnes' THEN 1 ELSE 0 END) as FieldNeeded1 FROM Persons;
Mar 12, 2009 #2 JoeAtWork Programmer Jul 31, 2005 2,285 CA I doubt that you can put a Case statement inside a Sum. Upvote 0 Downvote
Mar 12, 2009 #3 pjm IS-IT--Management Mar 21, 2001 125 DE Hi The Access equivalent would be:- Code: select sum (iif (city = 'Sandnes', 1, 0)) as fieldneeded1 from persons; pjm Upvote 0 Downvote
Hi The Access equivalent would be:- Code: select sum (iif (city = 'Sandnes', 1, 0)) as fieldneeded1 from persons; pjm
Mar 13, 2009 #4 dhookom Programmer Jun 24, 2003 22,519 US Or Code: SELECT Sum(Abs(city = 'Sandnes')) AS fieldneeded1 FROM persons; Duane Hook'D on Access MS Access MVP Upvote 0 Downvote
Or Code: SELECT Sum(Abs(city = 'Sandnes')) AS fieldneeded1 FROM persons; Duane Hook'D on Access MS Access MVP
Mar 13, 2009 #5 pjm IS-IT--Management Mar 21, 2001 125 DE ...or Code: select count (*) as fieldneeded from persons where city = 'Sandnes'; pjm Upvote 0 Downvote