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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:31:54+00:00 2026-06-06T20:31:54+00:00

I am dealing with an issue and need some expert advice on to achieve

  • 0

I am dealing with an issue and need some expert advice on to achieve the problem, my sql query generates output with two columns, 1st column displays id (for e.g. abc-123 in following table) and next column displays corresponding result to the id stored in db which is pass or fail.

I need to implement, when resolution is pass it should display success attempt, in following example, abc-123 failed 1st time however def-456 passed in next attempt thus success rate is 50%, now counter should reset and go to next row where there is pass thus it should show 100%, again when code hits pass counter resets then goes next and displays 33% bec there are two fail and one pass at the end, how it can be achieved in sql? (id and resolution are column names)

**date**       **id resolution**    
 6/6/2012     abc-123   fail       50%
 6/7/2012     abc-456   pass    
 6/8/2012     abc-789   pass       100%
 6/9/2012     abc-799   fail       33%
 6/10/2012    abc-800   fail    
 6/1/2012     abc-900   pass

Thanks

  • 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-06T20:31:55+00:00Added an answer on June 6, 2026 at 8:31 pm
    SELECT
      *
    FROM
      table
    INNER JOIN
    (
      SELECT
        MIN(g.id)   AS first_id,
        MAX(g.id)   AS last_id,
        COUNT(*)    AS group_size
      FROM
        table AS p
      INNER JOIN
        table AS g
          ON g.id > COALESCE(
                      (SELECT MAX(id) FROM table WHERE id < p.id AND resolution = 'pass'),
                      ''
                    )
         AND g.id <= p.id
      WHERE
        p.resolution = 'pass'
      GROUP BY
        p.id
    )
      AS groups
        ON  table.id >= groups.first_id
        AND table.id <= groups.last_id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi Everyone I m dealing with some serious issue in django-admin.I have created models
I am having an issue dealing with the notation used in a JSON file
I'm having a minor issue dealing with pointers to overloaded member functions in C++.
Hey so I've been dealing with this issue for a while. So, part of
For a period of time, I have been dealing with an issue in pagination
Ok, I was reading through this entry in the FQA dealing about the issue
Dealing with some legacy code and in trying to get a poorly designed database
I need to save a few informations about some files. Nothing too fancy so
I'm a completely self-taught Objective-C programmer, and I need advice on how to best
One issue that comes up during Pinax development is dealing with development versions of

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.