Skip to content
Advertisement

Count grouped dates in SQL

I currently have data looking like:

where grp is grouped consecutive dates. I want to count each of this grp, so with above data, I would like to get result of 5 (2 consecutive date groups for id 1, 3 consecutive date groups for id 2). Anyone have idea how to tackle this?

Advertisement

Answer

Do you just want count(distinct)? I don’t think Netezza supports multiple arguments as in:

So a subquery can be used:

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement