Home » RDBMS Server » Server Administration » unique rows
unique rows [message #371941] Mon, 25 December 2000 22:48 Go to next message
neelu
Messages: 5
Registered: December 2000
Junior Member
My doubt- I have a table like this

aa bb cc
101 ggg 201
102 hhh 202
103 nnn 203
104 nnn 204

I want a query which will give output like this-

aa bb cc
101 ggg 201
102 hhh 202
103 nnn 203
Regards
Neelu
Re: unique rows [message #371946 is a reply to message #371941] Tue, 26 December 2000 07:51 Go to previous messageGo to next message
Bala
Messages: 205
Registered: November 1999
Senior Member
Hi,
select aa, bb, cc from t1
where rowid in
(select min(rowid) from t1
group by bb);

aa bb cc
101 ggg 201
102 hhh 202
103 nnn 203
Re: unique rows [message #371954 is a reply to message #371941] Wed, 27 December 2000 00:47 Go to previous messageGo to next message
neelu
Messages: 5
Registered: December 2000
Junior Member
Hi Bala,
Your query worked fantastic.Thanks a lot.One more question, how to solve the same problem so that it works in SQL Server 7.0.
It is very urgent, it will be nice if you could do it fast. I wrote the same query,it doesn't understand rowid in SQL server. Hope for a reply.
Re: unique rows [message #371955 is a reply to message #371941] Wed, 27 December 2000 00:47 Go to previous messageGo to next message
neelu
Messages: 5
Registered: December 2000
Junior Member
Hi Bala,
Your query worked fantastic.Thanks a lot.One more question, how to solve the same problem so that it works in SQL Server 7.0.
It is very urgent, it will be nice if you could do it fast. I wrote the same query,it doesn't understand rowid in SQL server. Hope for a reply.
Re: unique rows [message #371958 is a reply to message #371941] Wed, 27 December 2000 07:48 Go to previous message
Bala
Messages: 205
Registered: November 1999
Senior Member
Here you go.......
if you have the first column 'aa' as a sequence in ascending order then

select aa, bb, cc from t1
where aa in
(select min(aa) from t1
group by bb);

Bala
Previous Topic: Help required
Next Topic: Function based indexes
Goto Forum:
  


Current Time: Fri May 17 11:39:48 CDT 2024