How to calculate median in postgres

Viewed 12395

I'm now stuck on calculation median on postgres because there is no function about calculation median in postgres. Following is my query and I want to get median value of that query. Please help me how to do it.

SELECT count, conversion, company_id FROM (SELECT count(ap.id), 
(count(ap.id)/cast(NULLIF(SUM(j.views), 0) as float) * 100) AS conversion, 
j.company_id FROM applications ap RIGHT JOIN jobs j ON ap.job_id = j.id GROUP BY j.company_id order by conversion) with_avg
1 Answers
Related