|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
SQL - Incorrect Syntax Error
I get an Incorrect Syntax error when adding the order by clause:Brad Roberts 04/30/04 10:33 A > From: Brad RobertsPhilip Arnold 04/30/04 10:38 A I had to change it a little, because I want NULL values to be last. PleaseBrad Roberts 04/30/04 12:17 P I get an Incorrect Syntax error when adding the order by clause: a.positionPhoto_sort = 0 DESC, a.positionPhoto_sort ASC, p.photo_id ASC This works in Access... is this not valid syntax in SQL Server? Thanks, Brad ----- Excess quoted text cut - see Original Post for more ----- We had a discussion similar to this regarding this type of expression in the SELECT part of SQL Server queries ORDER BY CASE WHEN a.positionPhoto_sort = 0 THEN 0 ELSE 1 END, a.positionPhoto_sort ASC CASE works similar to a SWITCH, but you can also treat it like an IF I had to change it a little, because I want NULL values to be last. Please let me know if there's any problem with this: ORDER BY CASE WHEN a.positionPhoto_sort IS NULL THEN 99999 ELSE 1 END, a.positionPhoto_sort ASC Thanks so much for your help! -Brad > I get an Incorrect Syntax error when adding the order by clause: > > a.positionPhoto_sort = 0 DESC, a.positionPhoto_sort ASC, > p.photo_id ASC > > This works in Access... is this not valid syntax in SQL Server? We had a discussion similar to this regarding this type of expression in the SELECT part of SQL Server queries ORDER BY CASE WHEN a.positionPhoto_sort = 0 THEN 0 ELSE 1 END, a.positionPhoto_sort ASC CASE works similar to a SWITCH, but you can also treat it like an IF
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||