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

  • Home
  • SEARCH
  • 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 8533465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:58:17+00:00 2026-06-11T09:58:17+00:00

I really don’t know how to put a query for this task. I need

  • 0

I really don’t know how to put a query for this task.

I need to get a time for the first row of each record in the table but every time when I have a group of same results I need to get the first one when it occurs and when signal is equal to 1.

I don’t know how to explain it correctly but I will make an example and you’ll see what I mean.

Records:

ID| Time | Serial | Signal
 1| 10:59|   12   |   1
 2| 11:00|   12   |   1
 3| 11:01|   12   |   1
 4| 11:01|   13   |   1
 5| 11:02|   12   |   0
 6| 11:03|   12   |   0
 7| 11:05|   13   |   1
 8| 11:07|   12   |   1

So I need this result:

ID| Time | Serial | Signal
 1| 10:59|   12   |   1
 4| 11:01|   13   |   1
 7| 11:05|   13   |   1
 8| 11:07|   12   |   1
  • 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-11T09:58:18+00:00Added an answer on June 11, 2026 at 9:58 am

    Your exact logic is not clear, from what I can gather you are looking to get each row where signal is 1 where the serial value changes from one time to another.

    This can be done using a variable to track the value of the serial in the previous row (variable @t in my query below).

    SELECT  ID, Time, `Serial`, `Signal`
    FROM    (   SELECT  ID,
                        Time,
                        `Serial`,
                        `Signal`,
                        CASE WHEN `Serial` = @t THEN 0 ELSE 1 END AS IsNew,
                        @t:= `Serial`
                FROM    T,
                        (SELECT @t:=0) t2
                ORDER BY Time
            ) t
    WHERE   IsNew = 1
    AND     `Signal` = 1
    

    SQL Fiddle

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

Sidebar

Related Questions

I really don't know how to title this question, but I need some help
I really don't know what is going on. It worked the first time, then
This is one of things that I really don't get. I know that it's
I really don't know squat about java memory management, so this is entirely my
I have this json object (which i don't really know what is inside) and
I really don't get why this is not working. I want to avoid a
I have this problem and really don't know how to solve this. I'm having
I really don't know how to express this question. But what I'm trying to
I really don't know, why this is so complex and hard just for reading
I really don't know how to word this question, so I'll give an example

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.