question

cpops15 avatar image
cpops15 asked

Not familiar with SQL need a countif like function to count like account numbers that show up on consecutive days within a specific group

I'm working with a database where I have explicit account numbers that are put in a specific group. I need to be able to create a function where like account numbers that show up on consecutive days are counted. So for example, account 15145 shows up on 10/01/19, 10/02/19, and 10/3/19. I need something that quickly groups those accounts and provides a day count of 3 for this account.

countfunctioncounting
1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

ThomasRushton avatar image ThomasRushton ♦♦ commented ·

It sounds a bit like the islands and gaps problem - perhaps try starting there? https://www.red-gate.com/simple-talk/sql/t-sql-programming/the-sql-of-gaps-and-islands-in-sequences/

0 Likes 0 ·

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.