To calculate the median in PostgreSQL, simply take the 50% percentile (no need to add extra functions or anything):
SELECT PERCENTILE_CONT(0.5) WITHIN GROUP(ORDER BY x) FROM t;
More Related Contents:
- What to do with null values when modeling and normalizing?
- Postgres: INSERT if does not exist already
- Truncating all tables in a Postgres database
- How can I drop all the tables in a PostgreSQL database?
- How to change PostgreSQL user password?
- How to get the count of current month Sunday’s in psql?
- Restore a postgres backup file using the command line?
- Running PostgreSQL in memory only
- How to close idle connections in PostgreSQL automatically?
- Refresh a materialized view automatically using a rule or notify
- postgresql – replace all instances of a string within text field
- Is it possible to have autoincrement number without it being an ID?
- PostgreSQL: Modify OWNER on all tables simultaneously in PostgreSQL
- How do I login and authenticate to Postgresql after a fresh install?
- PostgreSQL error ‘Could not connect to server: No such file or directory’
- Insert if not exists, else return id in postgresql
- function returns multiple columns as a single column instead of multiple columns
- Sequences not affected by transactions?
- Postgres: check if array field contains value?
- Dynamic pivot query using PostgreSQL 9.3
- PostgreSQL ERROR: canceling statement due to conflict with recovery
- Change type of varchar field to integer: “cannot be cast automatically to type integer”
- eliminate duplicate array values in postgres
- Find Parent Recursively using Query
- Is there a way to disable updates/deletes but still allow triggers to perform them?
- Error: Column does not exist in postgresql for update [duplicate]
- How to see the CREATE VIEW code for a view in PostgreSQL?
- How can I ensure that a materialized view is always up to date?
- PostgreSQL: Query has no destination for result data
- Error when pushing data to Heroku: time zone displacement out of range