【发布时间】:2020-09-04 05:17:02
【问题描述】:
我正在尝试通过将联接更改为在 study 和 id 和 datedate -1 上来转换我的查询(在一个表上是正常数据,在另一个表中是 date-1),但我我犯了一些错误,这给了我一个错误。
数据库:Oracle 并在 Denodo Server 上运行
外科医生
study id cal_dtm total
RSCLS CA10001 2020-08-11 52
RSCLS CA10001 2020-08-10 52
ETDLD CA20302 2020-08-11 99
ERGKG CA34524 2020-08-11 31
查询:
select
tt1.study,
tt1.id,
tt1.cal_dtm,
tt1.total,
tt1.total-coalesce(tt2.total, 0) as delta
from pedics tt1
left outer JOIN pedics tt2 on tt1.total = tt2.total
and extract(month from tt1.cal_dtm)-extract(month from tt2.cal_dtm)=1
使用引发错误所需的条件进行查询:
select
tt1.study,
tt1.id,
tt1.cal_dtm,
tt1.total,
(tt1.total-coalesce(tt2.total 0)) as delta
from pedics tt1
left outer JOIN pedics tt2 on tt1.study_name = tt2.study_name and tt1.site_id = tt2.site_id
and extract(month from tt1.cal_dtm)-extract(month from tt2.cal_dtm-1)
错误: 连接视图条件错误:函数'-(tt2.cal_dtm, '1')'的参数类型无效
【问题讨论】:
-
你的数据库是什么?
-
Oracle 并在 denodo 服务器上运行。
-
在您的查询中,您使用以下列:name、study_name、site_id,而在您的数据示例中没有这样的列?
-
我从没听说过 Denodo,但也许用
months_between()表达会更开心。 -
denodo 使用 vql 脚本