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 7794405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:45:54+00:00 2026-06-01T22:45:54+00:00

I have a table logging application activity. Each row contains a DateTime (Time) and

  • 0

I have a table logging application activity.
Each row contains a DateTime (“Time”) and an “EventType” column… (And obviously some others that are unimportant here)

I would like to be able to get a count of the number of different EventTypes that occur every hour.

I’m currently getting a basic count of a single EventType with:

select DATEADD(hh, (DATEDIFF(hh,0,Time)),0) as 'hour', count(*) as 'apploads' 
from PlaySessionEvent
where EventType = 0
Group By DATEADD(hh,(DATEDIFF(hh,0,Time)),0)
order by hour

What is the easiest way to extend this to count multiple different EventTypes within the same hour?

::Update

Should have specified, I havn’t just grouped by the EventType aswell because I only want a subset of all the EventTypes available. (ie. not boring trace/debug data)
Also, I wanted the different event types as columns, rather than additional rows duplicating the DateTime entries.

Eg…

DateTime           EventType1        EventType2
12:12:12 12/12/12  45                22

Apologies for the inexact initial question!

  • 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-01T22:45:55+00:00Added an answer on June 1, 2026 at 10:45 pm
    select EventType, DATEADD(hh, (DATEDIFF(hh,0,Time)),0) as 'hour', count(*) as 'apploads'  
    from PlaySessionEvent 
    where EventType = 0 
    Group By DATEADD(hh,(DATEDIFF(hh,0,Time)),0), EventType
    order by hour 
    

    Edit:

    New solution for the changed question:

    select DATEADD(hh, (DATEDIFF(hh,0,Time)),0) as 'hour', count(*) as 'apploads', 
    sum(case when EventType = 1 then 1 else 0 end) EventType1,
    sum(case when EventType = 2 then 1 else 0 end) EventType2
    from PlaySessionEvent 
    where EventType = 0 
    group By DATEDIFF(hh,0,Time)
    order by hour 
    

    Here is a slightly different way of writing it:

    select DATEADD(hh, (DATEDIFF(hh,0,Time)),0) as [hour], 
           COUNT(*) [apploads], 
           COUNT(case when EventType = 1 then 1 end) EventType1,
           COUNT(case when EventType = 2 then 1 end) EventType2
    from PlaySessionEvent 
    where EventType = 0 
    group By DATEDIFF(hh,0,Time)
    order by hour 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application that records activity in a table (Oracle 10g). The logging
I have a table containing events which happen in my application like people logging
In my application I have a strong requirement for logging each event for the
We have a project where data is written to a logging table. Now, when
I use SQL Server 2005. I have a simple logging table that my web
I have table with a unique auto-incremental primary key. Over time, entries may be
Suppose, you have a special log table of your application. What do you think
At my work we have an existing ASP.NET web application and are duplicating some
We have a PHP/MySQL application and I want to setup a logging mechanism to
We have a large management application and we do a lot of logging for

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.