このwhere句で正しい結果を得るのに苦労しています。私はそれが括弧の問題であることを知っています。助言がありますか?
WHERE a.EVENT_DATE Between &trend_dt And &enddate
AND a.INDICATOR Not In ('INQUIRY (NOS)','PCC')
And a.INDICATOR2 Not In ('CAT-NA','INQUIRY (NOS)')
And d.ACTIVE In ('C','F')
And d.ARCHIVE_STATUS in ('N','Y')
Or (d.ARCHIVE_STATUS Is Null)
ありがとう!
結果の問題は、Indicator 2 フィールドが空白になることがあり、Indictator 2 フィールドに何かがあるレコードのみを返すことです。
これはクエリです:
PROC SQL;
CREATE TABLE COMPLAINT_DATA_0 as
SELECT
a.EVENT_DATE,
a.INDICATOR,
a.INDICATOR2,
a.COMMITTEE_ACTION AS REVIEW_TYPE,
a.LEVEL_OF_EXCEPTION AS METHOD_RECD,
a.REFER_TO AS PLAN_NTWK,
b.DESCRIPTION AS SubCategory,
d.CROSSREF2 AS ConProvID,
d.LAST_NAME AS Provider,
a.MED_REC_NO AS MbrID,
a.CONFIRMED_BY AS IndProvID,
a.CODE_15 AS Severity,
MAX(c.INQUIRY_BODY) AS MaxProcStep,
e.Notes,
e.Notes2,
FROM VIPDBA.QA_PEER AS a LEFT JOIN VIPDBA.SYS_LOOKUPS AS b
ON a.INDICATOR2=b.CODE
LEFT JOIN VIPDBA.QA_PEER_INQUIRY AS c
ON a.LOOKUP_KEY=c.LOOKUP_KEY AND
a.MED_REC_NO=c.MED_REC_NO
LEFT JOIN VIPDBA.MASTER_CRED AS d
ON a.LOOKUP_KEY=d.LOOKUP_KEY
LEFT JOIN Complaint_Notes AS e
ON a.LOOKUP_KEY=e.LOOKUP_KEY AND
a.MED_REC_NO=e.MbrID
WHERE a.EVENT_DATE Between &trend_dt And &enddate
AND a.INDICATOR Not In ('INQUIRY (NOS)','PCC')
And a.INDICATOR2 Not In ('CAT-NA','INQUIRY (NOS)')
And d.ACTIVE In ('C','F')
And
( d.ARCHIVE_STATUS IN ('N','Y')
OR d.ARCHIVE_STATUS is null)
GROUP a.EVENT_DATE,
a.INDICATOR,
a.INDICATOR2,
b.DESCRIPTION,
d.CROSSREF2,
d.LAST_NAME,
a.MED_REC_NO,
a.CONFIRMED_BY,
a.CODE_15,
e.Notes,
e.Notes2,
d.archive_status,
d.active
ORDER BY
a.EVENT_DATE,
a.INDICATOR2,
b.DESCRIPTION,
d.CROSSREF2,
d.LAST_NAME
; 走る;