Results 1 to 2 of 2
  1. #1
    SMAlvarez is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2008
    Posts
    3

    sql syntax error

    Why does the following sql code gives a syntax error in Access? How can I fix it?



    Code:
    SELECT SUM(CASE WHEN City = 'Sandnes' THEN 1 ELSE 0 END) as FieldNeeded1
    FROM Persons;

  2. #2
    thhui is offline Competent Performer
    Windows XP Access 2002 (version 10.0)
    Join Date
    Feb 2009
    Posts
    235
    Try this instead:-
    Code:
    SELECT Sum(IIf([City]='Sandnes',1,0)) AS Sum
    FROM Persons;

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Hide zero value in report and date syntax
    By Alex Motilal in forum Access
    Replies: 0
    Last Post: 11-16-2008, 09:11 AM
  2. Syntax Error In Insert Into Statement
    By frankvfox in forum Queries
    Replies: 1
    Last Post: 09-09-2008, 12:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums