我有一个如下所示的查询:
SELECT
SUM (LIMIT_AMOUNT)
FROM
(SELECT
CTR_NO
, REPORT_DATE
, LIMIT_AMOUNT
, ROW_NUMBER()
OVER (PARTITION BY CTR_NO, REPORT_DATE ORDER BY REPORT_DATE) rn
FROM LOD_CONTRACT
WHERE
br_cst_code='3432434'
AND REPORT_DATE BETWEEN '20-FEB-15' AND '28-FEB-15') b
WHERE
b.rn=1;
如何为JPA管理的实体构建SQL查询,如:
SELECT
SUM (o.limit_amount)
FROM
(SELECT
o.ctr_no
, o.rpt_dt
, o.limit_amount
, ROW_NUMBER()
OVER (PARTITION BY o.ctr_no, o.rpt_dt ORDER BY o.rpt_dt) rn
FROM LOD_CONTRACT o
WHERE
o.br_cst_code='3432434'
AND o.rpt_dt BETWEEN '20-FEB-15' AND '28-FEB-15') b
WHERE
b.rn=1;
答案 0 :(得分:1)
JPQL当前不支持Oracle分区表。要使用此功能,您必须坚持使用本机查询。