My scenario is like below.
id email created_at
1 test1@gmail.com 2018-01-01
2 test1@gmail.com 2018-01-01
3 test2@gmail.com 2018-01-01
4 test3@gmail.com 2018-01-01
5 test4@gmail.com 2018-01-02
6 test1@gmail.com 2018-01-02
7 test1@gmail.com 2018-01-02
8 test5@gmail.com 2018-01-03
9 test4@gmail.com 2018-01-03
I want to get distinct email values on each day that are not exist in previous dates. If I group by date I will get results like below.
select count(distinct email) as count, created_at from test_table group by created_at
count created_at
3 2018-01-01
2 2018-01-02
2 2018-01-03
But I need result like below
count created_at
3 2018-01-01
1 2018-01-02
1 2018-01-03
Please provide solution to above.