Home > Net >  Postgres: Where value equal decimal value
Postgres: Where value equal decimal value

Time:03-31

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?

CodePudding user response:

Put it under single quotes :

select *
from dvbs_transponders
where freq = '11487.77'

DEMO

  • Related