Reg Global
ID | uom ID | uom
------------------ ----------------
1 | kg 1 | kg
1 | gm 1 | gm
1 | ml 3 | pl
3 | pl
Required Output : r_glob
ID | reg | glob
------------------
1 | ml | null
Tried query:
SELECT TA.id, TB.UOM
FROM TB
LEFT JOIN TA
ON TB.id=TA.id
WHERE TA.id like '8'
GROUP BY TA.id , TB.UOM;
Output: r_glob
ID | reg
------------------
1 | kg
1 | gm
答案 0 :(得分:0)
使用左外连接并检查表Global中的列中的空值。
select Reg.ID, Reg.uom as reg, Global.uom as glob
from Reg
left outer join Global on Reg.ID = Global.ID and Reg.uom = Global.uom
where Global.ID is null