select recname, rectype, max(updatable) updatable, recdescr from ( select b.RECNAME, c.rectype, case when min(mod(b.fielduse,2))=0 and min(a.hidden) = 0 then '1' else '0' END Updatable, c.recdescr from pspnlgroup a, pspnlfield b, psrecdefn c where a.pnlname = b.pnlname and b.recname = c.recname and a.pnlgrpname = '&1' and b.recname <> ' ' group by b.recname, c.rectype, c.recdescr union select b.RECNAME, c.rectype, case when min(mod(b.fielduse,2))=0 then '1' else '0' END Updatable, c.recdescr from pspnlfield b, psrecdefn c where b.recname = c.recname and b.recname <> ' ' and b.pnlname in ( select distinct subpnlname from pspnlgroup a, pspnlfield d where a.pnlname = d.pnlname and a.pnlgrpname = '&1' and subpnlname <> ' ' ) group by b.recname, c.rectype, c.recdescr order by 2,1 ) a group by recname, rectype, recdescr order by 2,3 desc,1 /