I have a relation in PostgreSQL named product which contains 2 fields: id and quantity, and I want to find the id of the
product
id
quantity
there is the 3rd variant
SELECT id FROM product WHERE quantity = (SELECT quantity FROM product ORDER BY quantity DESC NULLS LAST LIMIT 1)
if the table has btree index as (quantity DESC NULLS LAST) this variant will be super-fast