我不太了解oracle。我最近不得不将PHP / MySQL中的应用程序迁移到PHP / Oracle。当我使用Doctrine2时,我认为这不会那么难,但我在这里遇到了这个问题。这是Doctrine2生成的SQL:
SELECT a.*
FROM
(SELECT b0_.id AS id0,
b0_.created AS created1,
b1_.businessName AS businessName2,
b1_.isVerified AS isVerified3,
COUNT(b2_.id) AS sclr4
FROM br_merchants b1_
INNER JOIN br_user b0_
ON b1_.id = b0_.id
LEFT JOIN br_campaigns b2_
ON b1_.id = b2_.merchant_id
GROUP BY b0_.id,
b0_.created,
b1_.businessName,
b1_.isVerified
ORDER BY b2_.created DESC
) a
WHERE ROWNUM <= 10
我得到了ORA-00979: not a GROUP BY expression
。
我在某处读到了我需要指定group by语句中聚合functins未使用的所有列。我这样做但结果是一样的。
谁能告诉我哪里出错了!谢谢!
编辑:我做了ORDER BY 2 DESC
并且它在SQL Developer中工作,但是查询构建器不会使用2.所以如何在Doctrine2 querybuilder中执行此操作!
答案 0 :(得分:0)
我认为您的订单应该是ORDER BY b0_.created DESC
而不是ORDER BY b2_.created DESC
。当您尝试ORDER BY 2 DESC
时,它正在运行,因为您按第二列排序 - b0_.created