Posts

Showing posts with the label Window Functions

Calculating Median With Group By In AWS Redshift

Answer : The following will get you exactly the result you are looking for: SELECT distinct subject, median(num_students) over(partition by Subject) FROM course order by Subject; You simply need to remove the "over()" portion of it. SELECT subject, median(num_students) FROM course GROUP BY 1;