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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:38:34+00:00 2026-06-11T05:38:34+00:00

I have a table in mysql like this: I want to aggregation by 5mins,

  • 0

I have a table in mysql like this:

enter image description here

I want to aggregation by 5mins, so i create a procedure like this:

enter image description here

But, if the student_score changes(such as add another field), the procedure need to be updated.
If the student_score table has hundreds of fields, hundreds of assignment need to be writen in the procedure like “avg(src.score) as score”

My question is: is there a way make the procedure self-adaptive for the source table.

  • 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-11T05:38:35+00:00Added an answer on June 11, 2026 at 5:38 am

    Your mention of “procedure” suggests some kind of stored procedure on the database server, but I take it that you’re simply referring to a piece of application code or the SQL queries it creates, right?

    How to aggregate in 5 min intervals

    Average of data for every 5 minutes in the given times also discusses averaging. As I wrote in my answer there, I’d accomplish this using

    group by time div 500
    

    How to handle multiple score columns

    About having to duplicate the avg expression for every column, I see three solutions.

    One would be not to create a separate table at all, but instead simply do the averaging in every query where you actually access these averages. If those queries use only a subset of all columns, then you would only have to name and average those.

    The second solution would be generating the insertion query programatically. I.e. in the application from which you send these queries, have a piece of code query the db about the columns in the table, and construct the query to match. You could use this both for a real table (i.e. an insert statement) or a view (i.e. a create view statement).

    Thirdly, if your scores all have similar meaning, you might be better off normalizing your table in such a way that these multiple columns are turned into multiple rows, with columns name, time, kind and score, where the kind column would be some (possibly enum) value used to distinguish the different kinds of scores.

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

Sidebar

Related Questions

I have a table in mysql like this Name Result T1_09_03_2010 fail T2_09_03_2010 pass
I have a MySQL table like this: Payments +----+---------------------+---------+ | id | date (sorted
I have a MySQL table looking like this: > describe books; +---------------+--------------+------+-----+---------+----------------+ | Field
I have a mysql table that looks like this: id col2 col3 col4 1
I have a MySQL table structured somewhat like this: type name value ===================== 1
I have a MySQL table that looks like this: `id` int(10) unsigned NOT NULL
I have this mysql table called comments which looks like this: commentID parentID type
I have a MySQL table that looks something like this: +-----+------------+ | id |
I have an table structure like this mysql> SELECT id, name, parent_id FROM categories;
I have a table which looks like this: mysql> SHOW COLUMNS FROM Users; +------------+--------------+------+-----+---------+----------------+

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.