red23jordan red23jordan - 2 years ago 71
SQL Question

Use SQL to query in order except the first record

I have an idea, e.g. I have a table containing name(Ann, Ben, Chris, Tom, John),

I want to query it using sql from letter a first, z last.

But I have a condition that I want to put John in the first record.

Answer Source
select name
from names
order by
  case when name = 'John' then 0 else 1 end,
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download