错误代码:1111。无效使用组函数(SQL)

时间:2017-07-21 15:58:18

标签: mysql sql mysql-error-1111

我在MySQL中为牙科练习创建了这个查询

SELECT Paz.Nome, Paz.Cognome FROM Paziente AS Paz, Visita AS Vis WHERE Vis.Paziente=Paz.CF AND MAX(Vis.Parcella)=Vis.Parcella

但不适用于错误1111.请帮帮我

1 个答案:

答案 0 :(得分:1)

试试这个,我在连接中指定了第二个表,max语句需要采用子查询的形式:

SELECT 
Paz.Nome, 
Paz.Cognome 
FROM Paziente AS Paz
LEFT JOIN Visita AS Vis  ON Vis.Paziente=Paz.CF
WHERE  (SELECT MAX(Parcella) FROM Visita)=Vis.Parcella;