I created this query in MySQL for a dental practice
SELECT Paz.Nome, Paz.Cognome
FROM Paziente AS Paz, Visita AS Vis
WHERE Vis.Paziente=Paz.CF AND MAX(Vis.Parcella)=Vis.Parcella
But not work for the error 1111. Help me please
Try this, I've specified the second table in a join, the max statement needs to be in the form of a subquery:
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;