Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Select statement help (multiple record sets)

Status
Not open for further replies.

leprikon

IS-IT--Management
Jan 29, 2003
20
US
How would i select out the first records for each series below ?

12345 Abc123
12345 Abc456
12345 Abc756
22222 Bhgggg
22222 Gkjgkg
22222 jgjgjj
31111 kjlfdj
31111 lekf;r

I only want :

12345 Abc123
22222 Bhgggg
31111 kjlfdj
 
Try this

select col1,min(col2) from a group by col1


--My table is

create table a(col1 int,col2 varchar(20))

insert into a select 12345 ,'Abc123'
insert into a select 12345 ,'Abc456'
insert into a select 12345 ,'Abc756'
insert into a select 22222 ,'Bhgggg'
insert into a select 22222 ,'Gkjgkg'
insert into a select 22222 ,'jgjgjj'
insert into a select 31111 ,'kjlfdj'
insert into a select 31111 ,'lekf;r'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top