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; 

Comments

Popular posts from this blog

Chemistry - Bond Angles In NH3 And NCl3

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Change The Font Size Of Visual Studio Solution Explorer