Derby是否支持INTERVAL日期

时间:2019-02-19 05:41:08

标签: sql derby

我正在Apache Derby(10.14.2)上进行性能测试。我正在使用TPCH基准测试。我已经完成了TPCH的dbgen部分,并填充了数据库。 TPCH基准测试查询中有22个查询。我无法转换第一个查询以适合Apache Derby的语法。在生成文件中,我将数据库命名为DB2。由于那里没有Apache Derby选项。

查询如下:

select
l_returnflag,
l_linestatus,
sum(l_quantity) as sum_qty,
sum(l_extendedprice) as sum_base_price,
sum(l_extendedprice * (1 - l_discount)) as sum_disc_price,
sum(l_extendedprice * (1 - l_discount) * (1 + l_tax)) as sum_charge,
avg(l_quantity) as avg_qty,
avg(l_extendedprice) as avg_price,
avg(l_discount) as avg_disc,
count(*) as count_order
from
    lineitem
where
    l_shipdate <= '1998-12-01' - interval ':1' day (3)
group by
    l_returnflag,
    l_linestatus
order by
    l_returnflag,
    l_linestatus;

ij工具出现错误:

    ERROR 42X01: Syntax error: Encountered "\':1\'" at line 15, column 47.
Issue the 'help' command for general information on IJ command syntax.
Any unrecognized commands are treated as potential SQL commands and executed directly.
Consult your DBMS server reference documentation for details of the SQL syntax supported by your server.

有没有一种方法可以在TPCH中为Apache Derby生成查询。还是可以隐瞒对Apache Derby的查询的工具。

谢谢。

1 个答案:

答案 0 :(得分:1)

您可以尝试使用TIMESTAMPADD()函数:

WHERE l_shipdate <= CAST({fn TIMESTAMPADD(SQL_TSI_DAY, -1, CAST('1998-12-01 00:00:00' AS TIMESTAMP))} AS DATE)