Guys,Kindly please help me on how to get the derive result based on join statement. could not get the exact result. please see below sample data and result: thanks.CREATE TABLE #SAMPLE1(itemid nvarchar(35), inventtransid nvarchar(35), inventdimid nvarchar(35), JOURNALID nvarchar(35))INSERT INTO #SAMPLE1SELECT 'MOT2979','LT280264589','DIM4508728','PJ01716356' union allSELECT 'MOT2979','LT280264590','DIM7043874','PJ01716356'CREATE TABLE #SAMPLE2(itemid nvarchar(35), inventtransid nvarchar(35), toinventtransid nvarchar(35), inventdimid nvarchar(35), toinventdimid nvarchar(35), JOURNALID nvarchar(35))INSERT INTO #SAMPLE2SELECT 'MOT2979','LT280264589','LT280264590','DIM4508728','DIM7043874','PJ01716356' CREATE TABLE #SAMPLE3(inventdimid nvarchar(35), loation nvarchar(35))INSERT INTO #SAMPLE3SELECT 'DIM7043874','MARKET-L6' union allSELECT 'DIM4508728','PR-L4-13'RESULT:itemid----FROMLOCATION--TOLOCATIONMOT2979-- MARKET-L6----PR-L4-13