- Joined
- Jan 19, 2007
- Messages
- 467
- Likes received
- 1
- Thanks received
- 2
- Location
- UPS
Which DB are you using? I don't think there is an efficient way to do it but you could do:
select * from mytable where id_num in (select min(id_num) from table group by group_num)
select min(id_num) from tbl group by group_num
or
select min(id_num), group_num from tbl group by group_num
(if you need group_num included)
Or am i missing the point?
Assuming that the column types are integers and it's ok to get the lowest id_num from each group.
thanks, tried that one doesn't work cos you need id_num in group clause
if you only want the id_num column
....
select min(id_num) as id_num from tbl group by group_num
Or just:
Code:select min(id_num) as id_num from tbl group by group_num