Resolved: SQL Syntax
SELECT
*, AVG(salary)
FROM
salaries
WHERE
salary > 120000
GROUP BY emp_no
ORDER BY emp_no;
Now for the above query, everything is okay. But the syntax of the bold text is not clear to me. Using a * without a FROM and a comma after the *. Then there is AVG(salary). What is this?
1 answers ( 0 marked as helpful)
Hi Archisman!
Thanks for reaching out.
In this case, the AVG() Function will automatically obtain the average values of the field you've grouped by, which is emp_no. Therefore, the * indicates you are interesting in obtaining all rows from the salaries table, while later the GROUP BY clause will do the job in specifying which column you want to calculate the average values about.
Hope this helps.
Best,
Martin
Best,
Martin