I understand a lot of problems when comparing floats and complain about their use in this case - but I am not the author of the table and have only a small obstacle to climb ...
Someone decided to use floats as you would expect a GUID to be used. I need to get all records with a specific float value.
sp_help MyTable
-- Column_name Type Computed Length Prec
-- RandomGrouping float no 8 53
Here is my naive attempt:
SELECT RandomGrouping
FROM MyTable
WHERE RandomGrouping = 0.867153569942739
And here is a roughly working attempt:
SELECT RandomGrouping
FROM MyTable
WHERE RandomGrouping BETWEEN 0.867153569942739 - 0.00000001
AND 0.867153569942739 + 0.00000001
In my naive attempt, is this a literal floating point literal? Or is it really a decimal literal that will be converted later?
If my literal is not a floating point literal, what is the syntax for creating a floating point literal?
: ... , , . , , . , , .
EDIT: DVK.
TSQL - MSSQLServer SQL.
script , float:
DECLARE @X float
SELECT top 1 @X = RandomGrouping
FROM MyTable
WHERE RandomGrouping BETWEEN 0.839110948199148 - 0.000000000001
AND 0.839110948199148 + 0.000000000001
SELECT *
FROM MyTable
WHERE RandomGrouping = @X
"", . , .
, () . . .
Zinglon:
, , .
DECLARE @Y binary(8)
SET @Y = 0x3FEAD9FF34076378
SELECT *
FROM MyTable
WHERE convert(binary(8), RandomGrouping) = @Y