I am trying to compute a value in select statement itself but surprisingly it results in 0.
SELECT Top(1) Name,
LEN(Name) AS Equals,
Abs(LEN('Johny') - LEN(Name)) AS NotEquals,
LEN(Name)/(Abs(LEN('Johny') - LEN(Name)) + LEN(Name)) As Match
FROM Demo
WHERE Name = LEFT( 'Johny' , LEN(Name) )
ORDER BY LEN(Name) DESC
Output:
Name Equals NotEquals Match
John 4 1 0
Why exactly is value of match
field 0
in output?