IntermediateWHERE & Filtering

Find products with price ending in .99

The query

SQL
SELECT name, price
FROM products
WHERE price::TEXT LIKE '%.99'
   OR MOD(price * 100, 100) = 99
ORDER BY price;
Tested against PostgreSQL 16

Note

Two approaches: casting to TEXT and LIKE, or using MOD arithmetic. MOD is more accurate for decimals.

Tables referenced