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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:05:14+00:00 2026-06-04T14:05:14+00:00

I have a table like below Board Component Cost b1 c1 5 b1 c2

  • 0

I have a table like below

 Board Component Cost

    b1     c1       5
    b1     c2       10
    b2     c3       15
    b3     c4       20
    b3     c5       25
    b4     C6       25
  ---------------------
                  100%

I shoud give the input to get the values from the table, say…

If the input is 20%

the output should be

 Board Component Cost

    b1      c1      5
    b1      c2     10
    b2      c3     15

If the input is 50%

the output should be

 Board Component Cost

    b1      c1      5
    b1      c2     10
    b2      c3     15
    b3      c4     20

and so on

How to write the query in sql server

  • 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-04T14:05:15+00:00Added an answer on June 4, 2026 at 2:05 pm
    DECLARE @T TABLE (Col1 VARCHAR(10), Col2 VARCHAR(10), Col3 INT, SumValue Int)
    
    INSERT INTO @T(Col1, Col2, Col3)
    VALUES ('b1','c1',5)
    
    INSERT INTO @T(Col1, Col2, Col3)
    VALUES ('b1','c2',10)
    
    INSERT INTO @T(Col1, Col2, Col3)
    VALUES ('b2','c3',15)
    
    INSERT INTO @T(Col1, Col2, Col3)
    VALUES ('b3','c4',20)
    
    INSERT INTO @T(Col1, Col2, Col3)
    VALUES ('b3','c5',25)
    
    INSERT INTO @T(Col1, Col2, Col3)
    VALUES ('b4','C6',25) 
    
    DECLARE @SumValue INT
    
    UPDATE @T
    SET @SumValue=SumValue = ISNULL(@SumValue,0)+ Col3
    FROM @T T
    
    SELECT *
    FROM @T
    WHERE SumValue <= (
        SELECT TOP 1 SumValue
        FROM @T AS T
        WHERE T.SumValue>=40
        ORDER BY SumValue)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table like below. I want to be able to get a
I have a table like below <table id=mytable> <tr><th>checked</th><th>id</th><th>text</th></tr> <tr><td><input id=cb1 type=checkbox name=checker1/></td><td>123</td><td>abc</td></tr> <tr><td><input
i have a table like below: create table info (username varchar(30),otherinfo varchar(100)); now i
let say i have table look like below actionTable ----------- id, user, actionName, time
i have one table sql server like below , from that table i want
I have a table like below: EmployeeId EmployeeName RequestId RequestName EmployeeId RequestId I need
I have a table like below and its rows can be added and removed
I have a table like below: COL1 | COL2 | COL3 ______________________ ITEM1 |
need help in error in database pivot. i have table tamed table_score like below:
I have a history table like below CREATE TABLE [dbo].[t_PettyCash_History] ( [TableName] [varchar] (500)

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.