我有這樣的查詢。錯誤:語法錯誤在或接近「和」
select
ad.escore,
ad.mscore,
round(sum(ps.cnt)/sum(n.cnt) * 100,1) as percent
from
(
select
account_no,
-- 602 becomes '595-604'
to_char(trunc(empirica_score - 5, -1) + 5, '9999') || '-' || to_char(trunc(empirica_score - 5, -1) + 14, '9999') as escore,
-- 97 becomes '76-100'. Change the expression to group differently.
cast(((mfin_score - 1)/25) * 25 + 1 as text) || '-' || cast(((mfin_score - 1)/25) * 25 + 25 as text) as mscore
from account_details
) ad
join
(
select custno, count(*) as cnt
from paysoft_results
where result = 'Successful'
and resultdate >= '13/08/2014' <------- HERE
and resultdate <= '12/19/2014' <------- HERE
group by custno
) ps on ps.custno = ad.account_no
join
(
select customer_code, count(distinct start_date) as cnt
from naedo
and start_date >= '13/08/2014' <------- HERE
and start_date <= '12/19/2014' <------- HERE
group by customer_code
) n on n.customer_code = ad.account_no
group by ad.escore, ad.mscore;
它工作完美,如果我沒有像上面安裝的日期。
如果我把日期我會得到一個錯誤ERROR: syntax error at or near "and"
任何想法,爲什麼?
UPDATE
好吧,我想我可以問一個問題,現在,所以如果我可以追加在這一個。
ERROR: date/time field value out of range: "13/08/2014"
我的查詢日期比較。什麼是正確的方法來做到這一點?
莫爾納,更新可能應該是一個_new_問題,但我已經介紹了它在一邊,我原來的答覆。 – paxdiablo 2014-09-19 10:16:29
不**不依賴隱式數據類型轉換。始終使用適當的日期文字,而不是字符串常量。 ''13/08/2014''是一個字符串,不是日期。您應該使用Oracle的to_date()函數:'to_date('13/08/2014','DD/MM/YYYY')或者(稍短一點)ANSI日期文字:'date'2014-08-13' '。 – 2014-09-19 12:13:18