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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:32:52+00:00 2026-06-05T16:32:52+00:00

I have a SQL table with periodic measurements. I’d like to be able to

  • 0

I have a SQL table with periodic measurements. I’d like to be able to return some summary method (say SUM) over the value column, for an arbitrary number of rows at a time. So if I had

id  |  reading
1      10
5      14
7      10
11     12
13     18
14     16

I could sum over 2 rows at a time, getting (24, 22, 34), or I could sum 3 rows at a time and get (34, 46), if that makes sense. Note that the ID might not be contiguous — I just want to operate by row count, in sort order.

In the real world, the identifier is a timestamp, but I figure that (maybe after applying a unix_timestamp() call) anything that works for the simple case above should be applicable. If it matters, I’m trying to gracefully scale the number of results returned for a plot query — maybe there’s a smarter way to do this? I’d like the solution to be general, and not impose a particular storage mechanism/schema on the data.

  • 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-05T16:32:54+00:00Added an answer on June 5, 2026 at 4:32 pm

    You may resequense query result and then group it

    SET @seq = 0;
    
    SELECT SUM(data), ts FROM (
        SELECT @seq := @seq + 1 AS seq, data, ts FROM table ORDER BY ts LIMIT 50
    ) AS tmp GROUP BY floor(tmp.seq / 3);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an SQL table like this : sales(product,timestamp) I want to display a
I have a SQL table set that looks like this create table foo (
I have a SQL table with some normal fields and one xml-type field. I
I have a SQL table readings something like: id int client_id int device_id int
I have a sql table called UsersInAuthentication like ----------------------- | AuthUserId | UserId |
I have a sql table which has a date column (let say deployDate). Now
I have a SQL table that all of a sudden cannot return data unless
I have a SQL table with column which contain string like 'type|type1|type2|type3|type4'. I need
I have an SQL table with columns like this: Person | Property 1 |
I have an SQL table called trainings that looks like this: +-----+-----------+--------+------------+------------+------------+-------+ | Id

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.