Having this selection:
id IDSLOT N_UM ------------------------ 1 1 6 2 6 2 3 2 1 4 4 1 5 5 1 6 8 1 7 3 1 8 7 1 9 9 1 10 10 0
Here is one approach
Create table #t ( id int, IDSLOT int, N_UM int ) insert into #t ( id, idslot, n_um ) VALUES (1, 1, 6), (2,6,2), (3,2,1), (4,4,1), (5,5,1), (6,8,1), (7,3,1), (8,7,1), (9,9,1), (10, 10, 0) select Top 1 * from #t Where N_UM = ( select MIN(n_um) from #t )