hello,
i have a table in which i have to fill teh column Count. here is how it should be at the end:
.
the formula to fill the column Count should be:
if ID1=ID2 then Count =Count +1 else 1
for example for the ID=801428163, ID6<>ID5 so it 1; ID7=ID6 so count is 1+1=2 end so on.
i have tried something like this but it doesnt work:
declare @ val real
declare @ org_ID nvarchar
set @val=1
set @org_ID=[ID]
begin
update table
set [Count]= case when @org_ID=@org_ID-1 then @val=@val+1
else ' '
end
Something is wrong in this code and i cant figure it out what, besides the fact that it gives me an errror like
the syntax is incorrect near '=', i have a feeling that even if i wouldnt have received this error the result
would not have been the one which i look for.
thank you in advance , any suggestion would be highly appreciated!