Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- declare @t table(Id int, ColA int, ColB int, Isdefault bit);
- insert into @t values
- (1, 100, 96, 1),
- (2, 100, 96, 0),
- (3, 101, 98, 0),
- (4, 102, 99, 1);
- with cte as
- (
- select *, row_number() over(partition by ColA, ColB order by Isdefault desc) rn
- from @t
- )
- select Id, ColA, ColB, Isdefault
- from cte
- where rn = 1;
Add Comment
Please, Sign In to add comment