I have a table with the name of the files and the date they were created:

SELECT filepath, date FROM files ; filepath | date ---------------+---------------------------- file1 | 2018-05-10 12:40:02.888316 file2 | 2018-05-10 12:40:02.891425 file3 | 2018-05-10 12:43:49.406967 file4 | 2018-05-10 12:43:49.409698 file5 | 2018-04-27 16:45:40.312397 file6 | 2018-05-10 12:43:49.411634 

I know how to make a SELECT, to see what day how many files were created:

 SELECT count(*), date(date) FROM files group by date(date) order by date; count | date -------+------------ 15 | 2018-04-27 5 | 2018-04-28 7 | 2018-04-29 1 | 2018-04-30 14| 2018-05-01 11| 2018-05-02 

Tell me how to upload data so that it shows how many cfg files were on a specific date from the date column?

Needed output:

 count | date -------+------------ 15 | 2018-04-27 20 | 2018-04-28 27 | 2018-04-29 28 | 2018-04-30 42 | 2018-05-01 
  • What does cfg-файл mean? - user218976
  • I did not understand about cfg files. And what is bad working request? - Viktorov

1 answer 1

The cumulative total can be obtained using a window function indicating the sorting inside the window.

 select sum(count(1)) over(order by date(date)), date(date) from files group by date(date) 

Test on sqlfiddle.com