The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

SQL Syntax

SQL Syntax

Super Learner
0
Votes
1
Answer

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 Answer

365 Team

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

×
Online Data Science Training
SAVE 60%