Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. SELECT a."TheDate", COALESCE(b."recs", 0)
  2. FROM
  3. (
  4. SELECT CURRENT_DATE - i "TheDate"
  5. FROM generate_series(0, 29) i
  6. ) a
  7. LEFT OUTER JOIN (
  8. SELECT "TheDate", COUNT(*) "recs"
  9. FROM "Records"
  10. WHERE "TheDate" > (CURRENT_DATE - INTERVAL '30 DAY')::DATE
  11. GROUP BY "TheDate"
  12. )b ON a."TheDate"=b."TheDate"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement