Link to home
Create AccountLog in
Avatar of jackjohnson44
jackjohnson44

asked on

sql group on number range, not exact number

I have a column with a decimal which is a percentage .76, .24, 1.

I want to group on this column, but in .1 pt range, meaning group 0-.09, .1-.19, .2-.29.
ASKER CERTIFIED SOLUTION
Avatar of Steve Wales
Steve Wales
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Output as range text can be managed with
    convert(varchar(4), percent_grp) + ' - ' + convert(varchar(4), percent_grp + 0.09)
SOLUTION
Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
sjwales,

score is now truncated twice, which does not matter for the result, but is superfluous.
Oops!  You're right:

Joys of copy and paste :)