1. Additionals
2. Reprocesses
I am joining these two tables as one but only returning the DISTINCT work orders, preferably with calculated fields at the end of each indicating how many additionals and reprocesses are in each work order.
Here is what I have thus far:
Code: Select all
SELECT
*,
rw.id_defect,
rw.id_type,
rw.id_user,
rw.title,
rw.comment,
COUNT(rw.id_primary) AS rework_additionals,
COUNT(rw.id_primary) AS rework_reprocesses
FROM
erp_workorder_search AS wo
LEFT JOIN
erp_rework AS rw
ON
wo.id_primary = rw.id_workorder
WHERE
rw.id_type = 1 # Additional
OR
rw.id_type = 2 # ReprocessAny ideas?
Cheers,
Alex