• From a quick search on the firebird documentation, which almost made me believe that it wouldn't have a SUM() function, this seems to be close to what you need.

    SELECT part.num ,

    SUM(woitem.qtytarget) AS woitemqty,

    LIST(wo.num, ',') AS wonums

    FROM mo

    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 part ON woitem.partid = part.id

    GROUP BY part.num, mo.id

    On T-SQL, the concatenation could be something like this:

    SELECT part.num ,

    SUM(woitem.qtytarget) AS woitemqty,

    STUFF((SELECT ',' + wo.num

    FROM wo

    INNER JOIN moitem ON wo.moitemid = moitem.id

    WHERE moitem.moid = mo.id

    FOR XML PATH(''),TYPE).value('.', 'varchar(max)'),1,1,'') AS wonums

    FROM mo

    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 part ON woitem.partid = part.id

    GROUP BY part.num, mo.id

    The code might have errors because I can't test it without sample data.

    EDIT: To understand the concatenation in T-SQL, check the following article: http://www.sqlservercentral.com/articles/comma+separated+list/71700/

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2