The postgres documentation (http://www.postgresql.org/docs/9.1/static/tutorial-window.html) talks about window functions.
In their example:
SELECT salary, sum(salary) OVER (ORDER BY salary) FROM empsalary;
duplicates are handled as follows:
salary | sum
--------+-------
3500 | 3500
3900 | 7400
4200 | 11600
4500 | 16100
4800 | 25700 <-- notice duplicate rows have the same value
4800 | 25700 <-- SAME AS ABOVE
5000 | 30700
5200 | 41100 <-- same as next line
5200 | 41100 <--
6000 | 47100
(10 rows)
How do you do the same thing making it so that duplicate rows are NOT given the same value? In other words, I would like this table to look as follows:
salary | sum
--------+-------
3500 | 3500
3900 | 7400
4200 | 11600
4500 | 16100
4800 | 20900 <-- not the same as the next line
4800 | 25700 <--
5000 | 30700
5200 | 35900 <-- not the same as the next line
5200 | 41100 <--
6000 | 47100
(10 rows)