SELECT SERVICE_CENTER,
PRODUCT_CODE,
COMPANY_CODE,
REVENUE_SORT_CODE,
CONTROL_TYPE,
HISTORY_DATE,
STATUS_CODE
FROM CLIENT_HISTORY
WHERE (HISTORY_DATE = TO_DATE (‘2011-05-01 00:00:00’, ‘yyyy/mm/dd hh24:mi:ss’))
AND STATUS_CODE = ‘A’
AND CONTROL_TYPE NOT IN (‘X’,‘W’,‘O’)
AND SERVICE_CENTER IN (‘0010’,‘0060’,‘0056’,‘0040’,‘0020’,‘0055’,‘0052’,‘0032’,‘0030’,‘0036’,‘0034’,‘0062’,‘0069’,‘0070’,‘0073’,‘0075’,‘0076’)
SELECT SERVICE_CENTER,
PRODUCT_CODE,
COMPANY_CODE,
REVENUE_SORT_CODE,
CONTROL_TYPE,
HISTORY_DATE,
STATUS_CODE
FROM CLIENT_HISTORY
WHERE (HISTORY_DATE = TO_DATE (‘2011-05-01 00:00:00’, ‘yyyy/mm/dd hh24:mi:ss’))
AND STATUS_CODE = ‘A’
AND CONTROL_TYPE NOT IN (‘X’,‘W’,‘O’)
AND ((SERVICE_CENTER IN (‘0056’,‘0040’,‘0020’,‘0055’,‘0052’,‘0032’,‘0030’,‘0036’,‘0034’,‘0062’,‘0069’,‘0070’,‘0073’,‘0075’,‘0076’))
OR (SERVICE_CENTER IN(‘0060’,‘0010’) AND (REVENUE_SORT_CODE IS NULL OR REVENUE_SORT_CODE <> ‘8’ )))
AND ((PRODUCT_CODE NOT IN(‘3E’,‘3F’,‘42’,‘2R’,‘87’))
OR (PRODUCT_CODE IN (‘46’,‘47’,‘8Y’,‘8Z’) AND (REVENUE_SORT_CODE IS NULL OR REVENUE_SORT_CODE <> ‘==’)))
Again, I think my errors boil down to improper placement of text and/or commas, etc. Any assistance would be greatly appreciated. Thanks.
The following query runs and basically overselects by about 19,000 records - I can then bring the results into Excel or a db tool and delete down to the desired results. For some reason, Toad is not recognizing the code and not excluding things I want to exclude. Here is the query that runs fine, but overselects a bit:
AND PRODUCT_CODE NOT IN(‘3E’,‘3F’,‘42’,‘2R’,‘87’)
In addition to these criteria, I also want to add these two criteria which makes the whole thing break down:
(PRODUCT_CODE IN(46,47,8Y,8Z) AND REVENUE_SORT_CODE <> ‘==’)
(SERVICE_CENTER IN(‘0010’,‘0060’) AND REVENUE_SORT_CODE <> ‘8’)
HELP!!!
Below is the query that runs but yields crazy, incorrect results: