-1
In front of this database: Employee(employee, employee name, street, city) Works(employee, code company, salary) Company(code company, company name, city) Manager(employee, matricula_employed_manager)
I need to make this query: "Find the company that has the most employees."
My query:
SELECT c.nome_companhia, COUNT(t.matricula_empregado) AS Qtde
FROM companhia AS c, trabalha AS t, empregado AS e
WHERE t.codigo_companhia = c.codigo_companhia
AND t.matricula_empregado = e.matricula_empregado
GROUP BY c.nome_companhia HAVING Qtde = (SELECT MAX(Qtde));
Error displayed : Error Code: 1247. Reference 'Qtde' not supported (Reference to group Function)
Important you [Dit] your question and explain objectively and punctually the difficulty found, accompanied by a [mcve] of the problem and attempt to solve. To better enjoy the site, understand and avoid closures and negativities worth reading the Stack Overflow Survival Guide in English.
– Bacco