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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:10:42+00:00 2026-06-08T04:10:42+00:00

This query is designed to make a histogram with bin sizes of 50. So

  • 0

This query is designed to make a histogram with bin sizes of 50.
enter image description here

So as histograms go this means that there are 1013 objects with a count(*) between 0 and 49.

I would like to make the bin read like

0-49           1013
50-99          2147
100-149        1571

My attempt isn’t quit doing what I need

select interval + ' - '+interval*50-1 as bin,count(*) as number from
(

select  count(tblclaims.patientid) as counts, count(tblclaims.patientid)/50 as interval 
from tblclaims
inner join patient on patient.patientid=tblclaims.patientid
and patient.admissiondate = tblclaims.admissiondate
and patient.dischargedate=tblclaims.dischargedate
group by tblclaims.patientid


) as t
group by interval
order by bin

I know this is going to have cast the interval + ' - ' stuff as a varchar, but when I tried that things got way out of whack

  • 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-08T04:10:45+00:00Added an answer on June 8, 2026 at 4:10 am

    if the only problem is casting, You have to cast every number part apart :

    select cast(interval*50 as nvarchar(max)) + '-' + cast(interval*50+49 as nvarchar(max))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This query gives me syntax error in when-between line. how can i solve them?
This query that I have is returning therapists whose 'therapistTable.activated' is equal to false
I've got a DB structure that is designed to store attributes for specific objects
I inherited this hellish query designed for pagination in SQL Server. It's only getting
I previously designed the website I'm working on so that I'd just query the
I've got this POST form in my website designed to make groups out of
This Query is giving me an error of #1054 - Unknown column 'totalamount' in
this query SELECT * FROM tblContracts LEFT JOIN tblPartys ON tblContracts.id = tblPartys.Contract_id INNER
This query is somewhat related to this earlier one on sorting where, it was
This query works fine for me: $query = SELECT p.topnode_id, p.param_key, p.param_value FROM tbl_params

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.