How to find median by attribute with Postgres window functions?
问题 I use PostgreSQL and have records like this on groups of people: name | people | indicator --------+--------+----------- group 1 | 1000 | 1 group 2 | 100 | 2 group 3 | 2000 | 3 I need to find the indicator for the median person . The result should be group 3 | 2000 | 3 If I do select median(name) over (order by indicator) from table1 It will be group 2 . Not sure if I can select this with a window function. Generating 1000/2000 rows per record seems impractical, because I have millions of