Hi Praveen
select a.id,a.name,b.target,b.year from table1 a,table2 b
where a.id=b.id and 2>=(select count(distinct(d.target)) from table1
c,table2 d
where c.id=d.id and b.target<=d.target)
Thanks & regards
Mohan
-----Original Message-----
From: Praveen KR
[mailto:oracledba-ezmlmshield-x78249205.[Email address protected]
Sent: Thursday, May 05, 2005 4:49 PM
To: LazyDBA Discussion
Subject: doubt
hi pals,
Here is my question:
I have to get the top 2 people for each year who have achieved the
target.
Eg:
Year Name Target
1995 ABC 200
1995 XYZ 100
1996 XYZ 200
1996 PQR 100
Table Design
Table 1:
Id Name
1 ABC
2 XYZ
3 PQR
Table 2:
Tid id Year Target
1 1 1995 200
2 2 1995 100
3 3 1995 50
4 2 1996 200
5 1 1996 50
6 3 1996 100
Regards,
Praveen K R
______________________________________________________________________
--------
website: http://www.LazyDBA.com
Please don't reply to RTFM questions
Oracle documentation is here: http://tahiti.oracle.com
To unsubscribe: see http://www.lazydba.com/unsubscribe.html
To subscribe: see http://www.lazydba.com
By using this list you agree to these
terms:http://www.lazydba.com/legal.html
Disclaimer: This communication is for the exclusive use of the intended recipient(s) and shall not attach any liability on the originator or ITC Infotech India Ltd./its Holding company/ its Subsidiaries/ its Group Companies. If you are the addressee, the contents of this e-mail are intended for your use only and it shall not be forwarded to any third party, without first obtaining written authorization from the originator or ITC Infotech India Ltd./ its Holding company/its Subsidiaries/ its Group Companies. It may contain information which is confidential and legally privileged and the same shall not be used or dealt with by any third party in any manner whatsoever without the specific consent of ITC Infotech India Ltd./ its Holding company/ its Subsidiaries/ its Group Companies.
Oracle LazyDBA home page