1

In my case, both tables are details, sometimes it has 01 item in Tables A with mutiple items on Table B and vice versa.

SELECT DISTINCT
          x._PROCESS_INST_NO,  
          x._GOODS_CD,
          x._QTY,
          y._GOODS_CD,
          Y._QTY
     FROM [TBL_PROC_PM] x
LEFT OUTER JOIN (SELECT  t._PROCESS_INST_NO,
                    t._GOODS_CD,
                  t._QTY
             FROM [TBL_PROC_PMS] t ) y ON y._PROCESS_INST_NO = x._PROCESS_INST_NO
             WHERE y._PROCESS_INST_NO IN('631886','635312')

enter image description here

I want to remove the duplicated values from both sides. Please help. Thanks a lot!

  • Looks like you need a UNION, not a JOIN. What is the relationship between the 2 tables? – ypercubeᵀᴹ Nov 23 '18 at 8:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.