Good morning everyone, I hope someone can help me with the following question.
In MySQL I need to compare 2 identical tables filled by different employees and return when there is variation in the records, if there is variation, you must return the "part numbers", "quantity" and know if it belongs to table 1 or table 2. So I create a non-existent column called "TypeTable" but it returns me NULL.
This is query:
SELECT numParte
,Cantidad
,NULL AS "TypeTable"
FROM (
SELECT numParte
,SUM(Cantidad) AS Cantidad
,"TypeTable" AS "Table1"
FROM eboard.pye_hojadecarga
WHERE id_chklistemb = 'IDHDC-1-HY'
GROUP BY numParte
UNION ALL
SELECT numParte
,SUM(Cantidad) AS Cantidad
,"Table2"
FROM eboard.pye_hojaconfirmacion
WHERE id_hojadecarga = 'IDHDC-1-HY'
GROUP BY numParte
) tbl
GROUP BY numParte
,Cantidad
HAVING count(*) = 1
ORDER BY numParte;