Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8418505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T02:21:09+00:00 2026-06-10T02:21:09+00:00

I have a list of roughly 3000 rows. Each row has a different end

  • 0

I have a list of roughly 3000 rows. Each row has a different end time. see below

Fund name | Fund ID   | RedeemTime  | PurchaseTime | LatestTime  |
__________  _________  ____________   ____________ | ___________ |
Title1    | IDnumber  |  4:00:00    | 14:30:00     |  14:30:00   |
Title2    | IDnumber2 | 13:30:00    | 12:00:00     |  13:30:00   |
Title3    | IDnumber3 | 10:00:00    | 14:00:00     |  14:00:00   |
Title4    | IDnumber4 | 10:00:00    | 10:30:00     |  10:30:00   |

I am currently using a case statement for the 5th column to find the later of the two times.

I need to take the 5th column and provide a count of what happens each hour. For example on the table above the results would be

Hour     |  Count
_________ _______
10:00:00 |    1
13:00:00 |    1
14:00:00 |    2
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T02:21:11+00:00Added an answer on June 10, 2026 at 2:21 am

    You could “normalize” the two times in a subquery. You can generate a list of hours using a CTE. For example, for all hours in August 2012:

    ; with  HourList as
            (
            select  cast('2012-08-01' as datetime) as DateCol
            union all
            select  dateadd(hour, 1, DateCol)
            from    HourList
            where   dateadd(hour, 1, DateCol) < '2012-09-01'
            )
    select  hr.DateCol
    ,       count(yt.StartTime)
    from    HourList hr
    left join
            (
            select  case when time1 > time2 then time1 else time2 end as EndTime
            from    YourTable
            ) yt
    on      yt.EndTime <= hr.DateCol and hr.DateCol < dateadd(hour, 1, yt.EndTime)
    group by
            hr.DateCol
    option  (maxrecursion 0)
    

    If you don’t have a table filled with hours, there are ways to generate it. They all depend on your database. So if you’d like help with that, post which database you are using.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ordered list of movies. Each movie has a name and a
I have made a test with 10 M rows of data. Each row has
I have a structure that roughly looks like this: List<ProductLine> -> ID Name ...
I have a dictionary where each key has a list of variable length, eg:
i have list of rows that user select and i want to delete them,
I have roughly this code: ExecutorService threader = Executors.newFixedThreadPool(queue.size()); List futures = threader.invokeAll(queue); I
Here is roughly what I have: I have many companies that has many user
I have some map files consisting of 'polylines' (each line is just a list
I have a table that has patient information (name, dob, ssn, etc.) and a
I have list of input area in the form with id like contact1_title, contact2_title,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.