JPQL平均时差

Bud*_*tne 5 jpa jpql

我有订单单,收货单很好。任何账单可以有多个账单项。一个订单账单项目可能没有一个或多个接收账单项目。

我想计算提前期,这是订单和JPQL(Java持久性查询语言)查询中的收货之间的平均时间差。我使用EclipseLink 2.4作为持久性提供程序。

这是我尝试的查询。有什么办法可以使我使用JPQL的平均交货时间?

    jpql = "Select avg(b.createdAt - rb.createdAt) "
            + " from BillItem bi "
            + " join bi.bill b "
            + " joib bi.referanceBillItem rbi "
            + " join rbi.bill rb "
            + " where b.billType in :bts "
            + " and rb.billType in :rbts "
            + " and bi.item=:amp "
            + " and b.createdAt between :fd and :td "
            + " ";
Run Code Online (Sandbox Code Playgroud)