SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Counting distinct periods of consecutive days

By Harsha Majety,

My friend gave me an interesting problem yesterday. He works for a hospital and needs to count patient visits, and if a patient visits the doctor on consecutive days, it needs to be counted as 1 visit. Here is how i solved it. This is just one of many ways to do it.

Total article views: 1925 | Views in the last 30 days: 1
Related Articles

Visiting Atlantis

This week I got to visit Atlantis. Not the mythical island, but rather the ship, the Space Shuttle A...


SSC Editorial: A Visit to Microsoft

A Visit to Microsoft was posted back in August and I just re-read it. Here’s a quote that might inte...


Blog Changes on SQLServerCentral.com & Visiting The IndyTechFest

Perhaps you've noticed a few of the blog changes if you visit via the web rather than RSS. One good....


Visiting West Palm Beach SQL Group on April 29, 2009

I'm going to West Palm Beach on Apr 29th to visit Scott Klein and his group. I'll be doing a...


how to calculate duration spent on every visit

I have to show sessionID PageId Duration spent for a page visit