I would suggest:
SELECT COALESCE(O.SALESMAN_ID, 0) as SALESMAN_ID, SUM(OI.UNIT_PRICE * QUANTITY)
FROM ORDERS O JOIN
ORDER_ITEMS OI
ON o.ORDER_ID = OI.ORDER_ID. -- guessing at the relationship
GROUP BY COALESCE(O.SALESMAN_ID, 0)
ORDER BY COALESCE(O.SALESMAN_ID, 0);
Your query as written would produce non-sensical results. Always use proper, explicit, standard, readable JOIN
syntax. Never use commas in the FROM
clause.
CLICK HERE to find out more related problems solutions.