Last active
August 29, 2015 14:15
-
-
Save dzhlobo/14909fb21677ced48942 to your computer and use it in GitHub Desktop.
SQL float comparison
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MariaDB > SELECT id, summary_rating FROM companies ORDER BY summary_rating DESC; | |
+-------+----------------+ | |
| id | summary_rating | | |
+-------+----------------+ | |
| 75748 | 4.8 | | |
| 61769 | 4.76842 | | |
| 12475 | 4.59091 | | |
| 29849 | 4.54 | | |
+-------+----------------+ | |
MariaDB > SELECT COUNT(*) FROM `companies` WHERE summary_rating >= 4.59091; | |
+----------+ | |
| COUNT(*) | | |
+----------+ | |
| 2 | | |
+----------+ | |
MariaDB > SELECT COUNT(*) FROM `companies` WHERE summary_rating >= 4.59091 - 1e-6; | |
+----------+ | |
| COUNT(*) | | |
+----------+ | |
| 3 | | |
+----------+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment