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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T14:00:45+00:00 2026-06-17T14:00:45+00:00

I have a SQLite Database with the following structure: rowid ID startTimestamp endTimestamp subject

  • 0

I have a SQLite Database with the following structure:

rowid       ID                  startTimestamp   endTimestamp   subject
1           00:50:c2:63:10:1a   1000             1090           entrance
2           00:50:c2:63:10:1a   1100             1270           entrance
3           00:50:c2:63:10:1a   1300             1310           door1
4           00:50:c2:63:10:1a   1370             1400           entrance
.
.
.

I have prepared a sqlfiddle here: http://sqlfiddle.com/#!2/fe8c6/2

With this SQL-Query i can get the average differences between the endTime and the startTime between one row and the following row, sorted by subject and ID:

SELECT
    id,
    ( MAX(endtimestamp) - MIN(startTimestamp)
    - SUM(endtimestamp-startTimestamp)
    ) / (COUNT(*)-1) AS averageDifference
FROM
    table1
WHERE ID = '00:50:c2:63:10:1a'
AND subject = 'entrance'
GROUP BY id;

My problem: To calcute the average value is no problem, that does this query. But how can i
get the standard deviation and the variance of this values?

  • 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-17T14:00:46+00:00Added an answer on June 17, 2026 at 2:00 pm

    First finding the time differences of interest by joining the table to itself and grouping by ID, then finding the averages, variances as V(x) = E(x^2) - (E(x))^2 and standard deviation as sqrt(V)gives

    SELECT ID, AVG(diff) AS average,
           AVG(diff*diff) - AVG(diff)*AVG(diff) AS variance,
           SQRT(AVG(diff*diff) - AVG(diff)*AVG(diff)) AS stdev
    FROM
        (SELECT t1.id, t1.endTimestamp,
                min(t2.startTimeStamp) - t1.endTimestamp AS diff
        FROM table1 t1
        INNER JOIN table1 t2
        ON t2.ID = t1.ID AND t2.subject = t1.subject
        AND t2.startTimestamp > t1.startTimestamp  -- consider only later startTimestamps
        WHERE t1.subject = 'entrance'
        GROUP BY t1.id, t1.endTimestamp) AS diffs
    GROUP BY ID
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a database/table in SQLITE using the following structure CREATE TABLE milestones (
i have a table in sqlite database like following. id status ============= x 0
I am using a DBD::SQLite in memory database. I have defined the following indexes
I have a SQLite Database with a table called events, it has the following
I have made the following code to retrive data from SQLite database. public Cursor
Hi all i have the following table called student in SQLite database. this is
I'm trying to store enum in SQLite database using QSql. I have following class:
I have (in an SQLite database) the following string: Лампа в вытяжке на кухне
I have a big SQLite - Database that contains entries like this: rowID timestamp
I have following text in SQLITE database in TEXT field The exact date of

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.