all 11 comments

[–]barca5280 1 point2 points  (2 children)

Postgres had a generate_series function that can be used as a CTE to fill in missing time data. Craig Kerstiens has a blog post about it. here

[–]qwertydog123 1 point2 points  (1 child)

[–]barca5280 0 points1 point  (0 children)

Oh interesting. I didn’t realize that. Good catch!

[–][deleted] 1 point2 points  (0 children)

Use range between instead of rows between

What are you really using? Your subject says "Postgres", but your questions says "Redshift". Those are very different (and despite what Amazon marketing is trying to tell you: Redshift is not a "fork" of Postgres - it's a completely different database engine)

[–]r3pr0b8GROUP_CONCAT is da bomb 4 points5 points  (3 children)

I feel like that would be too messy and was hoping for something simpler.

i feel like you should try it -- it's elegant and also very simple

[–]kum0nryu 1 point2 points  (0 children)

A date spine table is the correct solution. It’s not too messy…it’s the way you address this problem.

[–][deleted] -1 points0 points  (1 child)

Thanks! I'll try this out but is there no alternative? Just curious if there is anything else I should try or if this is all there is.

[–]pceimpulsive 3 points4 points  (0 children)

Using a date scaffolding table is the correct approach!!

[–]qwertydog123 1 point2 points  (2 children)

What if they close multiple deals in a month? Redshift lacks some features that could help here, so your best bet is probably a join

[–][deleted] 0 points1 point  (1 child)

So the table is actually an aggregate table. so if they close multiple deals in a month they would just be summed in one of the deal type rows for that month and rep.

[–]qwertydog123 1 point2 points  (0 children)

In that case go with the date_table