Subject Aggregating a Union
Author Gordon Niessen
I am using FB1.5 and am trying to do a GROUP BY on the result of a
UNION, but some how the syntax is eluding me.

SELECT IC.item_id, IC.item_desc, SUM(IC1.qty), SUM(IC1.cost),
SUM(IC1.ext_cost)
FROM (
SELECT IC1.item_id, IC1.item_desc, -IC1.qty, -IC1.cost, -IC1.ext_cost
FROM ItemCost(12345) IC1
UNION
SELECT IC2.item_id, IC2.item_desc, IC1.qty, IC1.cost, IC1.ext_cost
FROM ItemCost(12350) IC2
) IC
GROUP BY IC.item_id, IC.item_desc

Do I have to embed the union set in a Stored Procedure to later do the
GROUP BY? I can't use a CASE on the qty, cost, and ext_cost by Order_ID
as the actual ItemCost is actually a Stored Procedure call and it does
not return Order_ID.

Or is this not possible in FB1.5? How about FB2.5?

--
Thanks,

Gordon