O'Reilly logo

MySQL 8 Cookbook by Karthik Appigatla

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

AVERAGE

Find the 10 employees with the highest average salaries:

mysql>  SELECT emp_no, AVG(salary) AS avg FROM salaries GROUP BY emp_no ORDER BY avg DESC LIMIT 10;+--------+-------------+| emp_no | avg         |+--------+-------------+| 109334 | 141835.3333 || 205000 | 141064.6364 ||  43624 | 138492.9444 || 493158 | 138312.8750 ||  37558 | 138215.8571 || 276633 | 136711.7333 || 238117 | 136026.2000 ||  46439 | 135747.7333 || 254466 | 135541.0625 || 253939 | 135042.2500 |+--------+-------------+10 rows in set (0.91 sec

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required