I have a table in a SQL Server 2008 database with a number column that I want to arrange on a scale 1 to 10.
Here is an example where the column (Scale
) is what I want to accomplish with SQL
Name Count (Scale)
----------------------
A 19 2
B 1 1
C 25 3
D 100 10
E 29 3
F 60 7
In my example above the min and max count is 1 and 100 (this could be different from day to day).
I want to get a number to which each record belongs to.
1 = 0-9
2 = 10-19
3 = 20-29 and so on...
It has to be dynamic because this data changes everyday so I can not use a WHERE
clause with static numbers like this: WHEN Count Between 0 and 10...