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
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:
Dieter