phpMyAdmin
 sql >> Database >  >> Database Tools >> phpMyAdmin

Query SQL max(), conteggio()

Per ottenere l'intera riga contenente il valore massimo puoi utilizzare ORDER BY ... DESC LIMIT 1 invece di MAX :

SELECT company_name, cnt
FROM (
    SELECT company_name, count(employee_name) AS cnt
    FROM works
    GROUP BY company_name
) w1
ORDER BY cnt DESC
LIMIT 1