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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:53:31+00:00 2026-06-14T18:53:31+00:00

Using a h2 database I want to get average values of a column while

  • 0

Using a h2 database I want to get average values of a column while grouping entries based on a timestamp.

My table looks like this:

TIME                    SID             SERVICE         TET     
2012-11-21 11:31:45.433 164DSQL0L4JW7   service1        3868    
2012-11-21 11:31:45.608 164DSS6TJS321   service2        350     
2012-11-21 11:31:45.711 164DSROS9DNXA   service2        285     
2012-11-21 11:31:45.766 164DSH2PMPY4M   service1        4044    
2012-11-21 11:31:45.778 164DSOGRCKG8J   service1        4248    
2012-11-21 11:31:45.82  164DSRMV0QMFT   service1        3766    
2012-11-21 11:31:46.089 164DSP1L9W6MC   service1        4257    
2012-11-21 11:31:46.226 164DSOPUNUFJF   service3        703     
2012-11-21 11:31:46.752 164DSLJHST6E8   service3        411     
2012-11-21 11:31:46.781 164DSHPI1T3J9   service3        393     
2012-11-21 11:31:45.24  164DSQI4RY330   service2        235     
2012-11-21 11:31:45.268 164DSPRDHROQN   service2        197     
2012-11-21 11:31:45.991 164DSRUUGQ8LN   service2        380     
2012-11-21 11:31:46.338 164DSMARDXMD3   service3        783  

I’d like to extract average values for the column TET grouped by the column TET.
I want to have the interval flexible (e.g. 15 seconds and for another query 5 minutes).

I found this question which is pretty much what I need, but unfortunately I can’t get any of the solutions to work in H2 (there’s no strftime).

  • 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-14T18:53:32+00:00Added an answer on June 14, 2026 at 6:53 pm

    H2 supports a number of date and time functions, for example DATEDIFF and DATEADD. Example:

    drop table if exists test;
    create table test(id int primary key, ts timestamp);
    insert into test 
    select x, dateadd(s, x, now()) from system_range(1, 100);
    select  dateadd(s, datediff(s, now(), ts) / 10 * 10, now()) as diff,
    avg(id) from test group by diff order by diff;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using PostgreSQL Database. I want to get a column values from a
I want to get records from the database using EF and assign the values
I want to get the last created table name from a MySQL database using
I want to get the data from a database table using a regular expression.This
I want to get the latest revision number of the SVN database using SVNKIT.
Using Access 2003 I want to get a table value from the two databases
I want to work with a file-based database using apache derby. I was wondering
i want to fetch information from the database using objects. i really like this
Hi guys I want to get Elephants list from database I am using this
I am using HSQLDB as my database. i want to get a primary key

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.