我不是交易程序員,但我知道一些SQL。我只需要另外一組代碼,因爲我不確定爲什麼會出現此錯誤。使用日期的ORA-01858錯誤
select
count(1) AH
from regmdr.contact_interaction ci
join regmdr.source_data sd on ci.sd_id = sd.sd_id
join regmdr.account_contact ac on ci.acct_cont_id = ac.acct_cont_id
join regmdr.account acc on ac.acc_id = acc.acc_id
where sd.sd_user_type in ('1','2')
and sd.sd_origin_reference = 'www.alliancehealth.com'
and ci.ci_create_date in (select case when ci.ci_create_date between to_date('1/1/2016','mm/dd/yyyy') and to_date('1/31/2016','mm/dd/yyyy') then 'January'
when ci.ci_create_date between to_date('2/1/2016','mm/dd/yyyy') and to_date('2/29/2016','mm/dd/yyyy') then 'February'
when ci.ci_create_date between to_date('3/1/2016','mm/dd/yyyy') and to_date('3/31/2016','mm/dd/yyyy') then 'March'
else '' end from regmdr.contact_interaction ci group by to_char(ci.ci_create_date, 'yyyy-mm')
請編輯您的帖子並使用源代碼標記以便查詢可讀。 –
乍一看,這是因爲你正在比較'1月','2月','3月'的ci.ci_create_date(這是一個日期)。還有其他問題 - 你正在按ci.ci_create_date =>'YYYYMM'分組,但它不是你選擇的一部分。 –