question

Am30 avatar image
Am30 asked

If i have names like g,a,z,p,k,x and i want an sql query so that the name P is displayed first and then the rest of the names in any order

@SirSQL @DaniSQL @BradleySQL

sql query
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
Jeff Moden avatar image
Jeff Moden answered

Here's one easy way...

 SELECT <<columnnames>>
   FROM <<someschemaname>>.<<sometablename>>
  ORDER BY IIF(name='p',0,1)
;

If the returns are huge, then a bit of trickery with an additional column in the table may be required to improve performance.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.