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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:25:23+00:00 2026-06-08T11:25:23+00:00

I have a query with rollup that outputs data like (the query is a

  • 0

I have a query with rollup that outputs data like (the query is a little busy, but I can post if necessary)

range    subCounts    Counts    percent
1-9      3            100       3.0
10-19    13           100       13.0
20-29    30           100       33.0
30-39    74           100       74.0
NULL     100          100       100.0

How is it possible to keep a running summation total of percent? Say I need to find the bottom 15 percentile, in this case 3+13=16 so I would like for the last row to be returned read

range    subCounts    counts    percent
10-19    13           100       13.0

EDIT1: here the query

select '$'+cast(+bin*10000 + ' ' as varchar(10)) + '-' + cast(bin*10000+9999 as varchar(10)) as bins, 
    count(*) as numbers,
    (select count(distinct patient.patientid) from patient 
    inner join tblclaims on patient.patientid = tblclaims.patientid
    and patient.admissiondate = tblclaims.admissiondate
    and patient.dischargedate = tblclaims.dischargedate
    inner join tblhospitals on tblhospitals.hospitalnpi = patient.hospitalnpi
    where (tblhospitals.hospitalname = 'X') 
    ) as Totals
    , round(100*count(*)/cast((select count(distinct patient.patientid) from patient 
    inner join tblclaims on patient.patientid = tblclaims.patientid
    and patient.admissiondate = tblclaims.admissiondate
    and patient.dischargedate = tblclaims.dischargedate
    inner join tblhospitals on tblhospitals.hospitalnpi = patient.hospitalnpi
    where (tblhospitals.hospitalname = 'X')) as float),2) as binsPercent


from
(

select tblclaims.patientid, sum(claimsmedicarepaid) as TotalCosts, 
    cast(sum(claimsmedicarePaid)/10000 as int) as bin
    from tblclaims inner join patient on patient.patientid = tblclaims.patientid
    and patient.admissiondate = tblclaims.admissiondate 
    and patient.dischargedate = tblclaims.dischargedate
    inner join tblhospitals on patient.hospitalnpi = tblhospitals.hospitalnpi
    where tblhospitals.hospitalname = 'X'
    group by tblclaims.patientid
)   as t 
group by bin with rollup
  • 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-08T11:25:25+00:00Added an answer on June 8, 2026 at 11:25 am

    OK, so for whomever might use this for reference I figured out what I needed to do.

    I added row_number() over(bin) as rownum to the query and saved all of this as a view.

    Then I used

    SELECT *,
              SUM(t2.binspercent) AS SUM
    FROM t t1
    INNER JOIN t t2 ON t1.rownum >= t2.rownum
    GROUP BY t1.rownum,
             t1.bins, t1.numbers, t1.uktotal, t1.binspercent
    ORDER BY t1.rownum
    

    by joining t1.rownum >=t2.rownum you can get the rolling count sort of thing.

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

Sidebar

Related Questions

I have query to show the table like this: but I want to PIVOT
I have query like that: (as You see I'd like to retrieve 50% of
I have query that gives back results like this: Client1 Product1 $500 Client1 Product2
I have query that goes like that : SELECT DISTINCT S.date1 AS date1, S.date2
I want to make one question about oracle/sql query. I have some data like
I have query like that in my DataSet (database is located in .mdf file):
I have query that looks like this declare @tmpTable Table(id int) insert into @tmpTable(id)
I have query that runs in the controller: $data['query'] = $this->Member->select_sql($id); $this->load->view('myform'); and then
I have query that work fine, but it has 2 the same subqueries SELECT
I have query like: SELECT * FROM uni_customer WHERE mobile REGEXP '^(1[3,4,5,8]){1}\\d{9}$' But there

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.