I'm trying to extract data from an Oracle database using proc sql and sum statement. I can do it fine without the sum statement but once I use the sum statement it doesn't. Please help. What's wrong with my code???
proc sql;
create table Practice.Shipment_Test as
select distinct
WHLSL_CUST_BILL_DOC_VW.RTL_CO_NUM,
WHLSL_CUST_BILL_DOC_ITEM_VW.SHIP_FROM_DC_NUM,
WHLSL_CUST_BILL_DOC_ITEM_VW.NG_ITEM_NUM,
WHLSL_CUST_BILL_DOC_ITEM_VW.UT_DESC,
SUM(ORIG_ORD_QTY),
SUM(SHIP_QTY )
from connection to odbc
(select distinct
DWS.WHLSL_CUST_BILL_DOC_VW.RTL_CO_NUM,
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.SHIP_FROM_DC_NUM,
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.NG_ITEM_NUM,
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.UT_DESC,
SUM(DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.ORIG_ORD_QTY),
SUM(DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.SHIP_QTY)
from
DWS.WHLSL_CUST_BILL_DOC_VW,
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW
where
(
(
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.BUS_DT =to_date('16-Oct-2001','dd-mm-yyyy')
)
)
and
DWS.WHLSL_CUST_BILL_DOC_VW.BILL_DOC_NUM =
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.BILL_DOC_NUM
and
DWS.WHLSL_CUST_BILL_DOC_VW.ADJ_NUM =
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.ADJ_NUM
group by
DWS.WHLSL_CUST_BILL_DOC_VW.RTL_CO_NUM,
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.SHIP_FROM_DC_NUM,
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.NG_ITEM_NUM,
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.UT_DESC);
quit;
run;
Thanks,
RookieDBO
proc sql;
create table Practice.Shipment_Test as
select distinct
WHLSL_CUST_BILL_DOC_VW.RTL_CO_NUM,
WHLSL_CUST_BILL_DOC_ITEM_VW.SHIP_FROM_DC_NUM,
WHLSL_CUST_BILL_DOC_ITEM_VW.NG_ITEM_NUM,
WHLSL_CUST_BILL_DOC_ITEM_VW.UT_DESC,
SUM(ORIG_ORD_QTY),
SUM(SHIP_QTY )
from connection to odbc
(select distinct
DWS.WHLSL_CUST_BILL_DOC_VW.RTL_CO_NUM,
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.SHIP_FROM_DC_NUM,
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.NG_ITEM_NUM,
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.UT_DESC,
SUM(DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.ORIG_ORD_QTY),
SUM(DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.SHIP_QTY)
from
DWS.WHLSL_CUST_BILL_DOC_VW,
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW
where
(
(
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.BUS_DT =to_date('16-Oct-2001','dd-mm-yyyy')
)
)
and
DWS.WHLSL_CUST_BILL_DOC_VW.BILL_DOC_NUM =
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.BILL_DOC_NUM
and
DWS.WHLSL_CUST_BILL_DOC_VW.ADJ_NUM =
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.ADJ_NUM
group by
DWS.WHLSL_CUST_BILL_DOC_VW.RTL_CO_NUM,
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.SHIP_FROM_DC_NUM,
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.NG_ITEM_NUM,
DWS.WHLSL_CUST_BILL_DOC_ITEM_VW.UT_DESC);
quit;
run;
Thanks,
RookieDBO