Column ReduceDuties.Confirmed_Time is : (Nvarchar type)
Confirmed_Time
|----------------|
| 5 |
| 3.5 |
| 10 |
| 15 |
| 18 |
I want to classify numbers.
Output desired:
1-9 => 2
9-19 => 3
I have tried:
select t.range as [score range], count(*) as [number of occurences]
from (
select convert (float , Confirmed_Time) as Taeid,
case when Confirmed_Time >= 1 and Confirmed_Time <= 9 then '0-9'
when Confirmed_Time > 9 and Confirmed_Time <= 19 then '9-19'
end as range
from ReduceDuties) t
group by t.range
But I get the following error :
Conversion failed when converting the nvarchar value '3.5' to data type int.
3.5is not an integer value? - Alex Yufloor()incase whenstatement, for instance,case when floor(Confirmed_Time >= 1... - SNRnvarcharin the first place? - LarnuConfirmed_Time >= 1.0 and Confirmed_Time <= 9.0. - Dan Guzmannvarchar@SNR ? Apart from that formatting should be handled in the presentation layer, I don't know of any regions where2 > 10. For the OP's data the "highest" value is'5'(and the lowest is'10'); which I doubt is intended. - Larnu