1.There are duplicates of part.num and I want to remove duplicates and add quantities of those duplicates into one single quantity.

Code is below


part.num , (woitem.qtytarget/wo.qtytarget) AS woitemqty,

(SELECT LIST(wo.num, ',') FROM wo INNER JOIN moitem ON wo.moitemid = moitem.id WHERE moitem.moid = mo.id) AS wonums

INNER JOIN moitem ON mo.id = moitem.moid

LEFT JOIN wo ON moitem.id = wo.moitemid

LEFT JOIN woitem ON wo.id = woitem.woid AND woitem.typeid = 10
LEFT JOIN (Select sum(woitem.qtytarget) as labor, woitem.woid, uom.code as uom
from woitem
JOIN part on woitem.partid = part.id and part.typeid = 21
JOIN uom on woitem.uomid = uom.id
group by 2,3) as labor on wo.id = labor.woid
LEFT JOIN part ON woitem.partid = part.id

Where part.num = 'xo254'

// So, There are many xo254, but they have different quantities and different MO numbers. I want to add quantities of all similar x0254 part numbers.