RE: doubt

RE: doubt

 

  



Try with this :

select b.tid, a.id, a.name, b.year, b.target
from a,b
where a.id=b.id
and 2>(select count(*)
from b bb
where bb.target>b.target
and bb.year=b.year)
order by b.year
/



Biswaranjan Rath
Subject Matter Expert
2-091-3354 (Amdocs Internal)
+91.20.2670.3239 (desk)
+91.20.2682.4925 ((fax)

AMDOCS > INTEGRATED CUSTOMER MANAGEMENT

-----Original Message-----
From: Praveen KR
[mailto:oracledba-ezmlmshield-x78249205.[Email address protected]
Sent: Thursday, May 05, 2005 2:19 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


The information contained in this message is proprietary of Amdocs,
protected from disclosure, and may be privileged.
The information is intended to be conveyed only to the designated recipient(s)
of the message. If the reader of this message is not the intended recipient,
you are hereby notified that any dissemination, use, distribution or copying of
this communication is strictly prohibited and may be unlawful.
If you have received this communication in error, please notify us immediately
by replying to the message and deleting it from your computer.
Thank you.

Oracle LazyDBA home page