Last answered:

28 Dec 2023

Posted on:

11 Dec 2023

0

Resolved: AVG's salaries are about the same, but what about the other benchmarks?

SELECT  
    e.gender,
    COUNT(e.gender) AS num_of_gender,
    AVG(s.salary) AS salary_mean,
    MAX(s.salary) AS max_salary,
    MIN(s.salary) AS min_salary
FROM
    employees e
        JOIN
    salaries s ON e.emp_no = s.emp_no
GROUP BY e.gender;


# The median might give us a clearer idea.

3 answers ( 1 marked as helpful)
Instructor
Posted on:

11 Dec 2023

0

Hi Jorge!
Thanks for reaching out!


Could you please support your question with further explanation about these benchmarks you are asking for? This can help us assist you better. Thank you.


Looking forward to your answer.
Best,
Tsvetelin

Posted on:

11 Dec 2023

0

Basically i was wondering if there is a direct way to compute the median of a numeric column in MySQL, or maybe in other SQL engines?

Instructor
Posted on:

28 Dec 2023

0

Hi Jorge!

Thanks for reaching out.

Currently, there is no pre-defined function in MySQL calculating the median of a set of values. Nor there is one in PostgreSQL or Microsoft SQL Server, apparently. It is up to the user to write/create such a function.

Hope this helps.
Best,
Martin

Submit an answer