Tuesday, April 7, 2020

Answer for Doubt in one query

https://365datascience.com/dwqa-answer/answer-for-doubt-in-one-query-2/ -

Hi Kshitij!

Thanks for providing the code. 

We don’t have a table called ‘mark’ in our database. But I presume you are referring to the salary field from the salaries table, right? And your student_id is actually the emp_no field, is that correct?

If this is indeed the case, then you have to clarify what do you exactly want to retrieve from the dataset. 

By definition, if you obtain an average value, it’s not a maximum value.

However, you may have actually wanted to extract all average salaries (just as they have been provided in the salaries table) and then retrieve the highest, say, 10 of them. Is this the case?

If yes, the following query may be the solution.


SELECT 
emp_no, ROUND(AVG(salary), 2) AS average_salary
FROM
salaries
GROUP BY emp_no
ORDER BY average_salary DESC
LIMIT 10;

Hope this helps.
Best,
Martin




#365datascience #DataScience #data #science #365datascience #BigData #tutorial #infographic #career #salary #education #howto #scientist #engineer #course #engineer #MachineLearning #machine #learning #certificate #udemy

No comments:

Post a Comment