select distinct
po.c_order_id as source_pohdr_id,
'WYOMING' as source_system,
v.vendor_code as vendor_code,
v.name as VENDOR_NAME,
trim(po.em_sc_program_code) as PROGRAM_CODE,
PGM.DESCRIPTION AS PROGRAM_NAME,
substr(ltrim(po.documentno),1,12) as PO_DOCUMENTNO,
cast(po.totallines as NUMBER(18,0)) as totallines,
po.grandtotal as grandtotal,
po.salesrep_id as source_person_id,
PER.NAME AS BUYER_NAME,
'WYOMING' as source_system,
PO.DATEPRINTED as PRINTED_DATE,
PO.CREATED AS CREATED_DATE
, POC.ORDER_TYPE
, POC.AGREEMENT_INDICATOR
, POC.SOURCE_JUSTIFICATION
, POC.PRICE_ANALYSIS
, POC.CONTRACT_PROVISIONS
, POC.GOVERNMENT_PROPERTY
, POC.SUBCONTRACTING_PLAN
, POC.PRIOR_CONSENT_REQUIREMENTS
, POC.AUDIT_STATUS_SYMBOL
, POC.PO_SUBCONTRACT_CLOSEOUT
from c_order po
left join sc_vendor v on ( po.c_bpartner_id = v.c_bpartner_id )
LEFT join SC_CUSTOMER SF on PO.ad_org_id = SF.ad_org_id and SF.FRONT_END = 'STORES'
LEFT join SC_CUSTOMER C ON C.C_BPARTNER_ID = PO.C_BPARTNER_ID
LEFT JOIN SC_PO_CLASSIFICATION POC ON po.C_ORDER_ID = POC.C_ORDER_ID
LEFT JOIN sc_program PGM ON TRIM(po.em_sc_program_code) = PGM.PROGRAM_CODE
LEFT JOIN SC_PERSON PER ON PO.SALESREP_ID = PER.SC_PERSON_ID
WHERE
po.issotrx = 'N' and PO.GRANDTOTAL>=3000
--and to_char(po.dateprinted,'MM-DD-YYYY') between '01-31-2003' and '07-03-2003'
AND to_char(po.dateprinted,'MM-DD-YYYY')>= '01-02-2003' and to_char(po.dateprinted,'MM-DD-YYYY') <= '01-31-2003'
AND trim(po.em_sc_program_code) not in('XXX','U495','U181','A607')
The above code should pull rows which have printeddate in 1/31/2003 to 7/3/2003.But for some reason its pulling from all the date ranges years available in that table.Not sure how to handle dates in oracle where clause.Oracle is an object-relational database management system. It supports a large number of languages and application development frameworks. Its primary languages are SQL, PL/SQL and Java, but it also includes support for C and C++. Oracle also has its own enterprise modules and application server software.
TRUSTED BY