What's wrong? - Something to do with lead.
I think this does what you want:Code:select ue, cod_id, CASE WHEN max_rtype = min_rtype THEN max_rtype ELSE 'N/A' END rtype, area from (select ue, cod_id, area, max(decode(r_type,'N/A',null,r_type)) over (partition by ue, cod_id) max_rtype, min(decode(r_type,'N/A',null,r_type)) over (partition by ue, cod_id) min_rtype from TAB_TEST2)




Reply With Quote