rewrite self joins using analytic functions

  • From: hrishy <hrishys@xxxxxxxxxxx>
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Thu, 18 Mar 2010 09:10:59 +0000 (GMT)

Hi
 
Any ideas on how to re-write this self join using Analytical functions
 
SELECT 
tab2.col1 ,
tab2.col2
sum(tab2.col3)
count(*) 
FROM 
tab1,tab2
WHERE tab1.col1      = tab2.col2
AND   tab1.col2  =   tab2.col2
AND   tab1.col4         = tab2.col3
AND   tab2.col3     < tab1.col3
AND tab2.col5         = 3
AND tab1.col5          = 4
AND tab2.col6 NOT IN(303,321)
AND tab1.col6     not in (322)
GROUP BY tab2.col1,tab2.col2


      

Other related posts: