Implement Partial sorted query in sql server 2005
Posted
by Brij
on Stack Overflow
See other posts from Stack Overflow
or by Brij
Published on 2010-03-23T08:18:49Z
Indexed on
2010/03/23
8:23 UTC
Read the original article
Hit count: 267
I have to show records in such a way that some selected records should come first. After this, another records come in sorted manner from the same table.
For example, If I select state having stateID = 5 then the corresponding record should come first. after this another records should come in sorted manner.
For this, I tried union but it shows all in sorted.
select state from statemaster where stateid=5
union all
select state from statemaster
where not stateid =5
order by state
Thanks
© Stack Overflow or respective owner