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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:37:42+00:00 2026-05-22T19:37:42+00:00

I have something like this: Name…..Value A………..10 B…………9 C…………8 Meaning, the values are in

  • 0

I have something like this:

 Name.....Value
 A...........10 
 B............9
 C............8

Meaning, the values are in descending order. I need to create a new table that will contain the values that make up 60% of the total values. So, this could be a pseudocode:

set Total = sum(value) 
set counter = 0 
foreach line from table OriginalTable do: 
counter = counter + value 
if counter > 0.6*Total then break
else insert line into FinalTable
end

As you can see, I’m parsing the sql lines here. I know this can be done using handlers, but I can’t get it to work. So, any solution using handlers or something else creative will be great.
It should also be in a reasonable time complexity – the solution how to select values that sum up to 60% of the total
works, but it’s slow as hell 🙁
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-05-22T19:37:43+00:00Added an answer on May 22, 2026 at 7:37 pm

    You’ll likely need to use the lead() or lag() window function, possibly with a recursive query to merge the rows together. See this related question:

    merge DATE-rows if episodes are in direct succession or overlapping

    And in case you’re using MySQL, you can work around the lack of window functions by using something like this:

    Mysql query problem

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

Sidebar

Related Questions

I have a table that looks something like this: Name Year Value A 2000
i have a table like this NAME VALUE ----------------- bla 1 bla 2 bla
I have something like this: @ if(Model.Name == Bob) { <div>blah blah blah</div> <table><tr><td>blah
I have something like this on my view: <input type=checkbox value=1 name=services-for /> <input
I have a sheet A that looks something like this: Name Phone Number Title
i have done something like this: <form action=validate.php method=get> Id :<input type=text name=pID/><br/><br/> Name
I have a text file which contains something like this: Hello, my name is
I have something like this: function showFunction () { // need position and place
I have something like this: [{'date': 1, 'value':5}, {'date':2,'value':3}, ...] and want to map
I have a list of dictionaries that looks something like this: toCSV = [{'name':'bob','age':25,'weight':200},{'name':'jim','age':31,'weight':180}]

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.