How do you calculate the median salary for each department using window functions?

You need to calculate the median salary for each department in the iv_employees table. Some salaries are NULL, and different employees may earn the same amount. One department has an even number of employees, while another has an odd number. Explain how you'd solve this using ROW_NUMBER and COUNT, without built-in median functions. Which rows should you include, how would you select the middle salaries, and what mistakes should you watch out for? You can explain your approach in words or sketch out some SQL pseudocode.

ExplainWindow functionsSeniorAnalystData Engineer