SQL Server subtract two values

I am trying two update a column where the difference between two values are <= 5.

My code :

update tn
set UreStasie1Klas1 = SubQuery.TelLyne
from Loggerdata as tn
join (
select Datum, MaksStasie1,MinStasie1,Stasie1
, count(Stasie1) as TelLyne
from Loggerdata
where (MaksStasie1 – Stasie1 <= 5 )

    group by
    ) as SubQuery

on SubQuery.Datum = tn.Datum

However I get an error message : Msg 102, Level 15, State 1, Line 8
Incorrect syntax near '–'.

How do I subtract two values from each other in the above query?

How do I calculate the absolute difference?

I am using SQL Community 2017.



the problem is in

where (MaksStasie1 – Stasie1 <= 5 )

the -
is something else
maybe you copy pasted the code from somewhere

just remove the -
and type it again

:slight_smile: :slight_smile:

The - is for minus ?


The - is for minus ?