I have a select statement that retrieves data and sorts the data by one of the columns, at the moment all the fields are sorting accordingly but I would like to have a specific row to always be the first and not be affected by the sort. Here is what I have done:
select distinct colID,
colA,
colB,
colC
from vw_dATA
where (colID = 1)
order by colB
>Solution :
You can combine multiple sorting criteria with a CASE statement. For example:
select *
from (
select distinct colID,
colA,
colB,
colC,
my_row_id
from vw_dATA
where colID = 1
) x
order by
case when my_row_id = 1234 then 1 else 2 end, -- first ordering criteria
colB -- rest of the ordering