The below query results in 2 rows. I added the last 'and' statement in order to only show the result where the height was the max height but, the report still returns 2 rows?
select ds.catnr, pd.part_no, pd.description, ds.packtyp, pd.qty_box, ds.planqty, ds.weight_g,
round((ds.planqty/pd.qty_box),'1') X, bom.av_part_no, lg.height, lg.length, lg.spine width, lg.part_no, lg.description
from oes_delsegview ds, part_description pd,
TABLE(leos_flatbom_pkg.GetFlatBOM(pd.part_no)) bom,
leos_gen_part_picture lg
where ds.ordnr = '0021565475'
and ds.posnr = '00002'
and ds.segnr = '001'
and ds.catnr = pd.catnr
and ds.prodtyp = pd.prodtyp
and ds.packtyp = pd.packtyp
and bom.prodtyp = 'KT'
and bom.av_part_no = lg.part_no
and lg.height = (select max(lg1.height) from leos_gen_part_picture lg1 where lg.part_no = lg1.part_no)
Why does the 'height = max(height)' not restrict my result and how can I change the script to only show the row where 'height = max(height)'?
Current result...
Required result...


heightof a particular row with it'smax(height)since you are retrieving it for everypart_no(where clause in inner select statement).