Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- declare @t table (
- id int
- ,code char(2)
- ,descriptor int
- )
- insert into @t
- select 1, 'a1', 10
- union select 1, 'a1', 20
- union select 1, 'a1', 30
- union select 2, 'b1', 10
- union select 2, 'b1', 20
- union select 2, 'b1', 30
- union select 2, 'b2', 10
- union select 2, 'b2', 20
- union select 2, 'b2', 30
- union select 3, 'c4', 10
- union select 3, 'c4', 20
- union select 3, 'c4', 30
- union select 3, 'c7', 10
- union select 3, 'c7', 20
- union select 3, 'c7', 30
- select *
- from @t as t
- where code = (select min(code) from @t where id = t.id)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement