我有这个 SQL 查询:
SELECT id, COUNT(*) AS price
FROM (SELECT * FROM rt WHERE somecondition) AS st
JOIN tt
ON st.id = tt.id
GROUP BY id;
现在,我想选择所有表中价格最高的行。我已经尝试过了,不幸的是它根本没有返回任何行:
SELECT id, COUNT(*) AS price
FROM (SELECT * FROM rt WHERE somecondition) AS st
JOIN tt
ON st.id = tt.id
GROUP BY id
HAVING price = MAX(price);
我有点迷茫,有人有任何指示吗?