Posting this solution as another has already been posted but I think an alternative might be required.
At first sight it looks as if you just want the table to be ordered by column
[a]
in which case you need (nod to @hypermellow)
select a, b, c from [table] order by a
which will produce
1 mass 32
2 seed 10
3 kadd 12
4 ssds 55
However your wording
Quote:
how to get particular row at first remaining records in same order
suggests that you might want something like
with CTE AS (
select a, b, c, 1 as rownum from [table] where b = 'mass'
UNION ALL
select a, b, c, 1 + ROW_NUMBER() OVER (ORDER BY b)
FROM [table] where b <> 'mass'
)
SELECT a, b, c FROM CTE order by rownum
which will produce results
1 mass 32
3 kadd 12
2 seed 10
4 ssds 55
The point of interest here is that I have manually assigned a
rownum
of 1 to the record I want first, then allowed sql to generate row numbers for me based on whichever order is required (I used column
[b]
just to highlight the difference) - note that I add
1
to the generated row number to ensure the sub-query doesn't end up with a rownum=1 to clash with my first query.
I then just UNION the two queries.
If you did only want a single record returned (in either case) then use
TOP 1
as suggested by Amaan23 (but your wording implies that this is not what you want)