Saturday, July 11, 2020

Answer for Showing more fields with MAX

https://365datascience.com/dwqa-answer/answer-for-showing-more-fields-with-max/ -

Hi Lisa!

Thanks for reaching out.

Please accept my apologies for the delayed response.

There are perhaps even more solutions but please consider the following two suggestions. 

Basically, we need to either use a subquery in order to specify the employee with what salary we are interested in.


SELECT 
MIN(s.salary), e.first_name
FROM
employees e
JOIN
(SELECT
salary, emp_no
FROM
salaries
ORDER BY salary ASC
LIMIT 1) s ON e.emp_no = s.emp_no;

Alternatively, we can take advantage of the ORDER BY clause to obtain/find the same value.


SELECT 
e.emp_no, s.salary, e.first_name, e.last_name
FROM
salaries s
JOIN
employees e ON s.emp_no = e.emp_no
ORDER BY salary ASC
LIMIT 1;

Hope this helps.
Best,
Martin

Please feel free to use these queries and adjust them in a way that will deliver precisely the information you are interested in.




#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