cancel
Showing results for 
Search instead for 
Did you mean: 

Is it possible to join these two tables together?

0 Kudos
99

I'm trying to join these two tables together, but I can't seem to get it to work:

Select T50."ItemCode", T50."Bin", T50."On Hand", T51."Counts Past 365", T51."Latest Count" from


(SELECT T0."ItemCode", T1."SL1Code" "Bin", Sum(T0."OnHand") "On Hand" FROM OITW T0 INNER JOIN OBIN T1 ON T0."DftBinAbs" = T1."AbsEntry" WHERE T0."WhsCode" like '01%%' GROUP BY T0."ItemCode", T1."SL1Code" ORDER BY T0."ItemCode", T1."SL1Code")
T50


Left Join T51 on T50."ItemCode" = T51."ItemCode" 


(SELECT T2."ItemCode", Count(T0."CountDate") "Counts Past 365", Max(T0."CountDate") "Latest Count" FROM OINC T0  INNER JOIN INC1 T1 ON T0."DocEntry" = T1."DocEntry" Right JOIN OITW T2 ON T1."ItemCode" = T2."ItemCode" WHERE T2."WhsCode" like '01%%' and  T0."CountDate" >= Add_Days(Current_Date,-365) GROUP BY T2."ItemCode" ORDER BY T2."ItemCode")
T51

Accepted Solutions (0)

Answers (1)

Answers (1)

kothandaraman_nagarajan
Active Contributor
0 Kudos

Hi,

Try this query,

Select T50."ItemCode", T50."Bin", T50."On Hand", T51."Counts Past 365", T51."Latest Count" from (SELECT T0."ItemCode", T1."SL1Code" "Bin", Sum(T0."OnHand") "On Hand" FROM OITW T0 INNER JOIN OBIN T1 ON T0."DftBinAbs" = T1."AbsEntry" WHERE T0."WhsCode" like '01%%' GROUP BY T0."ItemCode", T1."SL1Code" ) T50

Left Join

(SELECT T2."ItemCode", Count(T0."CountDate") "Counts Past 365", Max(T0."CountDate") "Latest Count" FROM OINC T0 INNER JOIN INC1 T1 ON T0."DocEntry" = T1."DocEntry" Right JOIN OITW T2 ON T1."ItemCode" = T2."ItemCode" WHERE T2."WhsCode" like '01%%' and T0."CountDate" >= Add_Days(Current_Date,-365) GROUP BY T2."ItemCode" )

T51 on T50."ItemCode" = T51."ItemCode"

ORDER BY T2."ItemCode"

Regards,

Nagarajan