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

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
if the only problem is casting, You have to cast every number part apart :