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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:25:04+00:00 2026-05-12T06:25:04+00:00

I have an events based table that I would like to produce a query,

  • 0

I have an events based table that I would like to produce a query, by minute for the number of events that were occuring.

For example, I have an event table like:

CREATE TABLE events (
     session_id  TEXT,
     event       TEXT,
     time_stamp  DATETIME
)

Which I have transformed into the following type of table:

CREATE TABLE sessions (
     session_id    TEXT,
     start_ts      DATETIME,
     end_ts        DATETIME,
     duration      INTEGER
);

Now I want to create a query that would group the sessions by a count of those that were active during a particular minute. Where I would essentially get back something like:

TIME_INTERVAL ACTIVE_SESSIONS
------------- ---------------
18:00         1
18:01         5
18:02         3
18:03         0
18:04         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-05-12T06:25:04+00:00Added an answer on May 12, 2026 at 6:25 am

    Ok, I think I got more what I wanted. It doesn’t account for intervals that are empty, but it is good enough for what I need.

    select strftime('%Y-%m-%dT%H:%M:00.000',start_ts) TIME_INTERVAL, 
        (select count(session_id) 
          from sessions s2 
          where strftime('%Y-%m-%dT%H:%M:00.000',s1.start_ts) between s2.start_ts and s2.end_ts) ACTIVE_SESSIONS
       from sessions s1
       group by strftime('%Y-%m-%dT%H:%M:00.000',start_ts);
    

    This will generate a row per minute for the period that the data covers with a count for the number of sessions that were had started (start_ts) but hadn’t finished (end_ts).

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

Sidebar

Related Questions

I have an Events table with a not-null date field. Based on a pivot
I have a function that adds change events for form items based on the
I have a class that handles events from a WinForms control. Based on what
I have a dataset that I'm trying to chunk up into "events" based on
I have a deep hierarchical model that looks like this: Accounts -> Venues ->Events
I have an on-line calendar of company events that is based in a sql
I have a WPF test app for evaluating event-based serial port communication (vs. polling
I want to show a tooltip based on mouse over event . I have
I have a base page, BasePage, that raises an event that displays messages to
I have a basic Window class that I need to have events such as

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.