将此SQL转换为Doctrine查询语言(DQL)

时间:2015-12-15 04:25:36

标签: doctrine-orm

我得到了以下SQL查询

SELECT a.*
FROM payment_schedule a, (
    SELECT loan_application_id, MAX(due_date) max_date
    FROM payment_schedule
    WHERE payment_type_id <> 3
    GROUP BY 1
) AS b
WHERE a.loan_application_id = b.loan_application_id
AND a.due_date = b.max_date

我想将其转换为DQL,我尝试了以下

SELECT
    a.*
FROM
    Loan\Entity\PaymentSchedule a, (
        SELECT
            IDENTITY(ps2.loanApplication), MAX(ps2.dueDate) max_date
        FROM
            Loan\Entity\PaymentSchedule ps2
        GROUP BY 1
    ) AS b
WHERE IDENTITY(a.loanApplication) = IDENTITY(b.loanApplication)
AND a.dueDate = b.max_date

这不起作用,我如何在DQL中构造这样的查询?

感谢。

0 个答案:

没有答案