I have a problem trying to combine two querys into one. The problem I am facing is that I need to SUM total orders and total returns and they are both stored as regular orders, the only difference is the order number. Any order <90000000
is an order and any order that is >90000000 is a return. I want two fields in my query DOLLARS_PURCHASED and DOLLARS_RETURNED. Here is my SQL code:
SELECT SUM(PROORD_M.SHP_NET) AS ["DOLLARS_PURCHASED"]
FROM PROORD_M INNER JOIN CDSADR_M ON PROORD_M.CTM_NBR=CDSADR_M.CTM_NBR
WHERE PROORD_M.CTM_NBR='000080991906' And PROORD_M.INV_DATE>=#1/1/2005# And CDSADR_M.ADR_CDE='STANDARD' And CDSADR_M.ADR_FLG='0' And PROORD_M.ORD_STA='F' AND PROORD_M.ORD_NUM<'90000000'
SELECT SUM(PROORD_M.SHP_NET) AS ["DOLLARS_RETURNED"]
FROM PROORD_M INNER JOIN CDSADR_M ON PROORD_M.CTM_NBR=CDSADR_M.CTM_NBR
WHERE PROORD_M.CTM_NBR='000080991906' And PROORD_M.INV_DATE>=#1/1/2005# And CDSADR_M.ADR_CDE='STANDARD' And CDSADR_M.ADR_FLG='0' And PROORD_M.ORD_STA='F' AND PROORD_M.ORD_NUM>'90000000';
How can I combine these into one qeury with the two fields I want?
Thanks in advance,
Tbonehwd
is an order and any order that is >90000000 is a return. I want two fields in my query DOLLARS_PURCHASED and DOLLARS_RETURNED. Here is my SQL code:
SELECT SUM(PROORD_M.SHP_NET) AS ["DOLLARS_PURCHASED"]
FROM PROORD_M INNER JOIN CDSADR_M ON PROORD_M.CTM_NBR=CDSADR_M.CTM_NBR
WHERE PROORD_M.CTM_NBR='000080991906' And PROORD_M.INV_DATE>=#1/1/2005# And CDSADR_M.ADR_CDE='STANDARD' And CDSADR_M.ADR_FLG='0' And PROORD_M.ORD_STA='F' AND PROORD_M.ORD_NUM<'90000000'
SELECT SUM(PROORD_M.SHP_NET) AS ["DOLLARS_RETURNED"]
FROM PROORD_M INNER JOIN CDSADR_M ON PROORD_M.CTM_NBR=CDSADR_M.CTM_NBR
WHERE PROORD_M.CTM_NBR='000080991906' And PROORD_M.INV_DATE>=#1/1/2005# And CDSADR_M.ADR_CDE='STANDARD' And CDSADR_M.ADR_FLG='0' And PROORD_M.ORD_STA='F' AND PROORD_M.ORD_NUM>'90000000';
How can I combine these into one qeury with the two fields I want?
Thanks in advance,
Tbonehwd