-
Hi,
I'm trying to write a query which pulls the distinct records from a table.
I've a table which has a primary key column(ID). One more significant field is move_id.Except the PK field all other fields are duplicated for some rows. But for each distinct move_id I've couple of rows with different PK values. But from which I want only one(any one).
Table Test:
ID move_id name ....
1 'xx' 'pp'
2 'xx' 'pp'
3 'xx' 'pp'
4 'yy' 'uu'
5 'yy' 'uu'
I'm trying to write a query which gives me
1 'xx' 'pp'
2 'yy' 'uu'
....
Thanks,
kkr
-
use rank function,
this may help U.
SELECT ename, sal
FROM
( SELECT ename, sal, RANK() OVER (ORDER BY sal DESC) as rank
FROM emp
)
WHERE rank <= 5;
rgds,
Cheers!
OraKid.
-
Hi KKR,
You can use the following queries.
select * from where rowid in
(select max(rowid) from group by move_id)
or
select * from where rowid in
(select min(rowid) from group by move_id)
Hope this will help you.
Regards,
Vijay R.
-
hi vijay
goodone
Cheers!
OraKid.
-
It works. Thanks everyone.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|