Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT a."TheDate", COALESCE(b."recs", 0)
- FROM
- (
- SELECT CURRENT_DATE - i "TheDate"
- FROM generate_series(0, 29) i
- ) a
- LEFT OUTER JOIN (
- SELECT "TheDate", COUNT(*) "recs"
- FROM "Records"
- WHERE "TheDate" > (CURRENT_DATE - INTERVAL '30 DAY')::DATE
- GROUP BY "TheDate"
- )b ON a."TheDate"=b."TheDate"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement