Advertisement
visionling

Calculate the table count of each day

Nov 16th, 2022
1,295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PostgreSQL 0.28 KB | Source Code | 0 0
  1. -- 计算前七天中每一天的 ci 表的行数.
  2. -- Calculate the rows count of ci table for each of the first seven days.
  3. select d::date, (select count(*) from ci where created_at < d) as count
  4. from generate_series(now()::date - interval '7' day, now()::date, interval '1' day) as d;
Tags: sql count
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement