red23jordan red23jordan - 6 months ago 11
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
select name
from names
order by
  case when name = 'John' then 0 else 1 end,
  name
Comments