|voters_id| created_at |
6 20/07/2022
7 21/07/2022
9 21/07/2022
14 22/07/2022
21 22/07/2022
The output that I want is:
----------------------------------------- > (old + today)
on date 20/07 i must have votation count= (0 +1) = 1
on date 21/07 i must have votation count= (1 +2) = 3
on date 22/07 i must have votation count= (3 +2) = 5
How should I write this query?
>Solution :
You can use count() with windowing function. ie:
select distinct created_at, count(*) over (order by created_at) as votes
from mytable;