Skip to content
Advertisement

Postgres: Where value equal decimal value

My table looks like this:

source table for query

When the WHERE clause is equal to value with decimal point I get no valid output like:

SELECT transponder_id 
FROM signals.dvbs_transponders t 
WHERE t.freq = 11487.77

Output: transponder_id = None

When the query is for integer value, query works correctly:

SELECT transponder_id 
FROM signals.dvbs_transponders t 
WHERE t.freq = 11470

Output: transponder_id = 1009

Also using BETWEEN query returns expected values

SELECT transponder_id 
FROM signals.dvbs_transponders t 
WHERE t.freq between 11487 and 11488

Output: transponder_id = 1010

Why is my query using ‘equal’ operator not working with decimal values? I don’t like the between solution as it require to set tolerance range. How the query should be defined to work also with decimal values?

Advertisement

Answer

Put it under single quotes :

select *
from dvbs_transponders
where freq = '11487.77'

DEMO

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement