Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

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?

>Solution :

Put it under single quotes :

select *
from dvbs_transponders
where freq = '11487.77'

DEMO

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading