House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

SQL - Incorrect Syntax Error

  << Previous Post |  RSS |  Sort Oldest First |  Sort Latest First |  Subscribe to this Group Next >> 
Top  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Brad Roberts
04/30/2004 10:33 AM

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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Philip Arnold
04/30/2004 10:38 AM

----- 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

Top  |   Parent  |   Reply  |   Original Post  |   RSS Feed  |   Subscribe to this Group
Author:
Brad Roberts
04/30/2004 12:17 PM

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


<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

May 24, 2012

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference