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!

SQL Query with CASE WHEN

Status
Not open for further replies.

sqltimmy

Programmer
May 29, 2002
7
US
I'm getting syntax errors about missing operators when I use a query that is similar to:

SELECT CASE
WHEN (column1 > 0) THEN '1'
WHEN (column1 = 0) THEN '0'
WHEN (column1 < 0) THEN '-1'
END AS field1
FROM table1

It works fine in MS SQL Server, where I first wrote the query, but apparently copying and pasting it into an Access query doesn't work. Does anyone know the syntax for a CASE WHEN statement, or an alternative? Thanks!

 
SELECT IIF(column1 > 0,'1',IIF(column1=0,'0','-1')) AS field1
FROM table1;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top