Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to select based of priority

Author  Topic 

waterduck
Aged Yak Warrior

982 Posts

Posted - 2011-10-25 : 23:10:05
declare @a table(col1 smallint, col2 char(2))
insert into @a select
1,'p' union all select
1,'a' union all select
1,'q' union all select
2,'c' union all select
2,'d' union all select
2,'e' union all select
3,'fa' union all select
3,'p' union all select
4,'p' union all select
5,'ga';

'p' is priority.

desire output
1,'p'
2,'c' <--- any record will do...not necessary must be 'c'
3,'p'
4,'p'
5,'ga'

waterduck
Aged Yak Warrior

982 Posts

Posted - 2011-10-25 : 23:55:18
done with row_number
Go to Top of Page
   

- Advertisement -