I am trying to figure out how to run a percent_rank on a table, but filter which records the percent_rank is run on, but still include those rows that were filtered out, but give them a 0 percent_rank
For example, I have a users table and everyone has a point value assigned to them. I only want to percent_rank on people with >= 20 points, but not exclude them from the results. Meaning if they have 19 points I can still see their record, but their rank is 0
For example:
SELECT name,points,PERCENT_RANK() OVER (ORDER BY points)
FROM users
WHERE points >= 20;
But keep the people with less than 20 points in the results.