下面是我正在运行的一个查询,用于获取定位日期不在交易日期和交易日期-60之间的所有帐户。当我运行它时,查询会返回这些不正确的行。在研究这个问题时,我确保所有日期都在同一时间(它们都被定义为
date
不
timestamp
).
编辑:我也试着把日期放进去
trunc()
和
to_date()
但无济于事。
以下是我收到的日期值:
skip_locate :22-AUG-13
transaction_date :30-AUG-13
transaction_date - 60 :01-JUL-13
第二版:对于那些想知道日期的人,如果他们真的是2013年的:
skip_locate :2013-08-22 00:00:00
transaction_date :2013-08-30 00:00:00
transaction_date - 60 :2013-07-01 00:00:00
当我四处玩耍时,当我拿走
NOT
在
NOT BETWEEN
我没有得到任何结果。这是错误的,因为skip_locate实际上介于这两个日期之间。
以下是查询:
SELECT DISTINCT rl.complaint_date,
rl.complaint_amt,
rl.date_served1,
rl.date_served2,
rl.judgement_date,
rl.skip_locate,
lcc.bal_range_min,
lcc.bal_range_max,
lcc.cost_range_min,
lcc.cost_range_max,
lcc.court,
ah.ACCOUNT,
ah.transaction_code,
ah.transaction_date,
ah.transaction_date - 60 "t - 60",
ah.rule_id,
ah.amount,
ah.description,
r.state,
r.zip_code,
z.county
FROM racctrel r,
ziplist z,
legal_court_cost lcc,
racctlgl rl,
legal_transaction_review ah
WHERE substr(r.zip_code,1,5) = z.zip
AND r.state = lcc.state
AND REPLACE(lcc.county,' ','') = REPLACE(upper(z.county),' ','')
AND r.ACCOUNT = rl.ACCOUNT
AND r.ACCOUNT = ah.ACCOUNT
AND lcc.transaction_code = ah.transaction_code
AND lcc.transaction_code in (2,31)
AND lcc.end_date IS NULL
AND ah.batch_id = 257
and rl.skip_locate not between ah.transaction_date and ah.transaction_date - 60;