I'm simplifying my actual queries, but hope this gets across what I'm trying to do, here goes:
QUERY 1
RESULT
MODEL SALES QTY
ABC123 5
ABC124 5
QUERY 2
RESULT
MODEL OUT SALES QTY
ABC123 5
ABC124 5
ABC125 5
ABC126 5
I looking to achieve this result:
RESULT
MODEL SALES QTY OUT SALES QTY
ABC123 5 5
ABC124 5 5
I know the above query won't work but I need to look up in another table where OUT_MODEL = SA_MODEL for each of the results in the SALES table. I don't think I can join them as the criteria in the second query would effect the results of the first. Any idea of how I can acheive this?
QUERY 1
Code:
SELECT SA_MODEL,SALES_QTY FROM SALES
MODEL SALES QTY
ABC123 5
ABC124 5
QUERY 2
Code:
SELECT OUT_MODEL,OUT_SALES_QTY FROM TRANS WHERE IT_STATUS = 'A' AND IH_CREDIT = ' AND IH_STKSAVE = '
MODEL OUT SALES QTY
ABC123 5
ABC124 5
ABC125 5
ABC126 5
I looking to achieve this result:
RESULT
MODEL SALES QTY OUT SALES QTY
ABC123 5 5
ABC124 5 5
Code:
SELECT SA_MODEL,SALES_QTY, (SELECT OUT_MODEL,OUT_SALES_QTY FROM TRANS WHERE IT_STATUS = 'A' AND IH_CREDIT = ' AND IH_STKSAVE = ' AND OUT_MODEL = SA_MODEL) AS OUT_SALES_QTY FROM SALES