Note position: relative keeps the element in the normal flow but enables offset with top/right/bottom/left. Its main use is establishing a positioning context for absolutely positioned children.
SELECT
first_name,
salary,PERCENT_RANK()OVER(ORDERBY salary)AS pct_rank,CUME_DIST()OVER(ORDERBY salary)AS cumulative_dist
FROM employees;
Output
-- first_name | salary | pct_rank | cumulative_dist
-- Dave | 50000 | 0.00 | 0.25
-- Carol | 65000 | 0.33 | 0.50
-- Bob | 82000 | 0.67 | 0.75
-- Alice | 95000 | 1.00 | 1.00
Note PERCENT_RANK returns (rank - 1) / (total - 1), ranging from 0 to 1. CUME_DIST returns the fraction of rows with values less than or equal to the current row. Both are useful for percentile analysis.
Frequently asked questions
How does HTML & CSS handle position relative?
This task is covered in 2 stacks on this page: HTML & CSS, SQL. The "Position Relative" snippet in HTML & CSS uses `position: relative;`.
Which code does the HTML & CSS example use?
The "Position Relative" snippet uses `position: relative;`, from the Layout & Positioning section of the HTML & CSS cheat sheet.
Which stacks cover "position relative" on this page?
HTML & CSS, SQL. Together they hold 2 copy-ready snippets for this task.
Is there anything to watch out for?
Yes. For "Position Relative": position: relative keeps the element in the normal flow but enables offset with top/right/bottom/left. Its main use is establishing a positioning context for absolutely positioned children.