Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

Query Rewriting. - response (2) by dnoeth

$
0
0

Yes, both seem to do the same, but why do you create a Volatile Table instead if directly using it in a Derived Table?
I'm not shure but you probably want the minimum Lvl_Nbr for the maximum HIER_Rel_Detail, which seems to be much simpler: 

SELECT  A.Ten_Dig_Val,A.SUP_Ten_Dig_Val
FROM    Rel_Detail A join Ten_Dig_Val_list Temp2
on   A.Ten_Dig_Val=B.Ten_Dig_Val
AND A.HIER_Rel_Detail = B.HIER_Rel_Detail
qualify
   row_number() 
   over(partition by Ten_Dig_Val 
        order by HIER_Rel_Detail desc, Lvl_Nbr)=1

Dieter


Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>