title: Count number of visits between specific time frames
body: <p>I have a table sample data is given below </p>
  
  <pre><code>Id  TokenNo TokenType   GeneratedAt
  249 I1      W           2019-11-30 11:07:08.083
  250 I2      W           2019-11-30 11:07:25.230
  251 O1      W           2019-11-30 11:07:35.350
  252 D1      W           2019-11-30 11:58:00.643
  253 O2      W           2019-11-30 11:59:13.370
  254 I3      W           2019-11-30 12:02:59.000
  255 D2      W           2019-11-30 12:04:15.617
  </code></pre>
  
  <p>Script to generate sample data</p>
  
  <pre><code>insert into tab values 
  (249,'I1','W','2019-11-30 11:07:08.083'),
  (250,'I2','W','2019-11-30 11:07:25.230'),
  (251,'O1','W','2019-11-30 11:07:35.350'),
  (252,'D1','W','2019-11-30 11:58:00.643'),
  (253,'O2','W','2019-11-30 11:59:13.370'),
  (254,'I3','W','2019-11-30 12:02:59.000'),
  (255,'D2','W','2019-11-30 12:04:15.617')
  </code></pre>
  
  <p>I wish to calculate the count of records (customer visits) in different time frames.</p>
  
  <p>Expected Output</p>
  
  <pre><code>TimeFrame       Count
  7 AM            0
  10 AM           7    -- as per the sample data count between 10 AM and 1 PM
  1 PM            0
  4 PM            0
  7 PM            0
  10 PM           0
  </code></pre>
  
  <p>And after that i wish to convert the result to comma delimited output which i will do with the help of Stored Procedure</p>
  
  <pre><code>declare @res varchar(max)
  select @res= coalesce(@res+',','')+  col from table 
  </code></pre>