想知道我能不能不用子查询

SELECT *
FROM tbl_name
WHERE id = 123456
AND attempts = (
    SELECT MAX(attempts)
    FROM tbl_name
    WHERE id = 123456
)

想做这样的事
SELECT *
FROM tbl_name
WHERE id = 123456
AND attempts = MAX(attempts)

当我尝试时,我得到了这个:
ERROR:  aggregates not allowed

最佳答案

简言之,答案是否定的,不能将聚合值和非聚合值混合使用

10-04 14:54