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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:37:16+00:00 2026-06-14T05:37:16+00:00

Assume I have the following table: data_point (creation_datetime DATETIME PRIMARY KEY, data_point INTEGER); I

  • 0

Assume I have the following table:

data_point (creation_datetime DATETIME PRIMARY KEY, 
            data_point INTEGER);

I am looking for an SQL query that would not only tell me if the most recent entry has a data_point value of X, but how many consecutive rows after it also have X as a value.

For instance, assuming the following data:

creation_datetime       data_point
2012-10-31 12:00:00     0
2012-10-31 11:55:00     0
2012-10-31 11:50:00     0
2012-10-31 11:45:00     2
2012-10-31 11:40:00     0

If i had X=0, the number I would want back here would be 3, because the most recent value matches X, and the next 2 rows also match it.

I don’t have any ID column or anything. I could add one if need be, but I’d like to avoid it.

  • 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-14T05:37:17+00:00Added an answer on June 14, 2026 at 5:37 am
    select count(*) as num
    from data_point
    where creation_datetime > (
      select max(creation_datetime)
      from data_point
      where data_point <> 0
    )
    

    Counts the number of records after the last record that was not your desired value.

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

Sidebar

Related Questions

Assume I have a table that has the following structure: ================= | Id |
Assume we have the following data in a SQL Server table (sorted by name)
Assume I have the following style table, col1 col2 and col3 have same value
Assume I have the following input in Pig: some And I would like to
I have a basic recursive table setup in SQL 2008 with the following structure:
I need to perform the following on MySQL/InnoDB. Assume I have a table consists
Assume I'm running a website that shows funny cat pictures. I have a table
Assume I have the following ; def test(): while 1: a = b time.sleep(60)
Assume I have the following arrays: N = 8 M = 4 a =
Assume I have the following string: Hellotoevryone<img height=115 width=150 alt= src=/Content/Edt/image/b4976875-8dfb-444c-8b32-cc b47b2d81e0.jpg />Iamsogladtoseeall. This

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.