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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:17:06+00:00 2026-06-04T19:17:06+00:00

I have a database table like this: id date value minute 1 20100201 00:00:01.909

  • 0

I have a database table like this:

id     date                     value    minute
1      20100201 00:00:01.909    xxx      0   
2      20100201 00:00:02.408    xxx      0
3      20100201 00:01:02.412    xxx      1 
4      20100201 00:01:02.909    xxx      1 
5      20100201 00:01:02.921    xxx      1   
6      20100201 00:01:02.955    xxx      1
7      20100201 00:02:01.903    xxx      2
8      20100201 00:02:25.332    xxx      2
9      20100201 00:03:12.003    xxx      3
10     20100201 00:04:12.003    xxx      4

…

I want the results to be:

id    date                      value1   minute
1      20100201 00:00:01.909    xxx      0   
2      20100201 00:00:02.408    xxx      0
3      20100201 00:01:02.412    xxx      1
6      20100201 00:01:02.955    xxx      1
7      20100201 00:02:01.903    xxx      2
8      20100201 00:02:25.332    xxx      2
9      20100201 00:03:12.003    xxx      3

I want to query it and return the id with the first & last number for each minute and 1 record per minute if only 1 exists (so id 1,2,3,6,7,8,9 in the above).

I’ve tried using group by ordering by id ASC – group by minute but it seems to order after its grouped, so this doesn’t work.

Anyone got any ideas? I can’t believe it can’t be done!

  • 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-04T19:17:07+00:00Added an answer on June 4, 2026 at 7:17 pm

    Try this query –

    SELECT t1.* FROM test_table t1
      JOIN (
        SELECT MIN(id) min_id, MAX(id) max_id FROM test_table
          GROUP BY TIME_TO_SEC(TIME(date)) DIV 60) t2
      ON t1.id = t2.min_id OR t1.id = t2.max_id
    

    If date field is not a DATETIME or TIMESTAMP, then GROUP BY should be modified.
    Also, I advise you to group by exact minute (e.g. – group by year, day_of_year, minute_of_day).

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

Sidebar

Related Questions

i have database table like this +-------+--------------+----------+ | id | ip | date |
I always forget how to do things like this. I have a database table
I have a MySQL database table called Participant that looks something like this: (idParticipant)
I have a question. My database table is something like this: | ID |
I have a table like this in my database (SQL Server 2008) ID Type
I have a database application in which a group is modeled like this: TABLE
I have written a function to print database table to an array like this
I have a table in my database like this: [id] [uniqueidentifier] NOT NULL, [user_id]
I have a table in my postgresql 8.4 database like this: id(serial), event_type_id(id, foreign
I have user table having fields gender and first name like this.. The value

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.