1
我使用下面的查询,但得到的错误设置CASE语句,以便所有的结果类型为VARCHAR
'Conversion failed when converting the varchar value '8-14' to data type int.'
我相信它,因为第二行是返回一个整数,其余的不是,是正确的?
我不打算计算这个字段,所以如果他们都需要是相同类型的值,让第二行返回为varchar会很好。我尝试过使用'convert',但是我不想我认为我的语法没错。
,(case when AppointmentCancellationDate = null Then 'NoDate'
when (datediff(day,BasicStartDate,AppointmentCancellationDate)) < '8' then (datediff(day,BasicStartDate,AppointmentCancellationDate))
when (datediff(day,BasicStartDate,AppointmentCancellationDate)) <15 then '8-14'
when (datediff(day,BasicStartDate,AppointmentCancellationDate)) <22 then '15-21'
Else '+22' end) as CancWindowGroup
感谢看起来像它的工作 –
并从'<'8''更改为'<8' –
并将'= null'更改为'为空' – TriV