0
我試圖使用一個案例選擇如果一天是星期一(或d等於2),'其他'將處理每週的其他一天。什麼是星期選擇案例的語法?
Select to_char (sysdate, 'D') d from dual,
/*if 2 or Monday then run this part*/
CASE
2
Then
SELECT DISTINCT RPAD(CLAIM.CLAIM_NUMBER, 20) ||
LPAD(CLAIM.CLAIM_ID, 15, '0') ||
TO_CHAR(CLAIM.INCIDENT_DATE, 'MMDDYYYY') ||
LPAD(' ',2) ||
'D'
FROM CLAIM,CLAIMANT,INSURER,POLICY
WHERE CLAIM.CLAIM_ID = CLAIMANT.CLAIM_ID
AND POLICY.INSURER_NUMBER = INSURER.INSURER_NUMBER
AND INSURER.INSURER_NUMBER NOT IN ('7','8')
AND CLAIMANT.EXAMINER1_CODE NOT IN ('MAYCONV')
AND CLAIM.INSURANCE_TYPE = 2
AND CLAIM.JURISDICTION_CODE <> 1
AND CLAIMANT.CLAIMANT_TYPE_CODE in (4,7)
/*if Monday then go 2 days back*/
AND CLAIMANT.EDIT_DATE > (SYSDATE - 2)
/*if not equal to 2 or any day but Monday then run this part*/
Else
SELECT DISTINCT RPAD(CLAIM.CLAIM_NUMBER, 20) ||
LPAD(CLAIM.CLAIM_ID, 15, '0') ||
TO_CHAR(CLAIM.INCIDENT_DATE, 'MMDDYYYY') ||
LPAD(' ',2) ||
'D'
FROM CLAIM,CLAIMANT,INSURER,POLICY
WHERE CLAIM.CLAIM_ID = CLAIMANT.CLAIM_ID
AND POLICY.INSURER_NUMBER = INSURER.INSURER_NUMBER
AND INSURER.INSURER_NUMBER NOT IN ('7','8')
AND CLAIMANT.EXAMINER1_CODE NOT IN ('MAYCONV')
AND CLAIM.INSURANCE_TYPE = 2
AND CLAIM.JURISDICTION_CODE <> 1
AND CLAIMANT.CLAIMANT_TYPE_CODE in (4,7)
/*if not Monday then go 1 day back*/
AND CLAIMANT.EDIT_DATE > (SYSDATE - 1)
/
側面問題,但你應該知道[NLS設置影響日數](http://stackoverflow.com/a/14518463/266304);其他人以不同的語言環境運行您的代碼可能會看到不同的結果。 –