sql server - a select statement that assigns a value to a variable must not be combined with data-retrieval -
for example had 1 variale @rev data retieval shown in query
"select distinct @accno,illness_id,desc_id,'lab',labname,lr.result,'positive','false',@sex
@rev=case when datediff(day,@admitdate,lr.labdatetime)<0 1 else datediff(day,@admitdate,lr.labdatetime) end
i wanna use variable in same select query clause as
l.labdatetime between @admitdate , dateadd(hh,24*@rev,@admitdate)
can var value there ..?
this error occurs when assigning column values select statement local variables not columns assigned corresponding local variable.
may can try way
select @rev=case when datediff(day,@admitdate,lr.labdatetime)<0 1 else datediff(day,@admitdate,lr.labdatetime) end select distinct @accno,illness_id,desc_id,'lab',labname,lr.result,'positive','false',@sex,@rev
Comments
Post a Comment