Paste this into a new question or an answer at dba.stackexchange.com:
<!-- --> > create table product as > select generate_series(1, 10, 1) as id, random() as quantity > > <pre> 10 rows affected > </pre> <!-- --> > SELECT id FROM product WHERE quantity >= ALL(SELECT quantity FROM product) > > <pre> > | id | > | -: | > | 4 | > </pre> <!-- --> > SELECT id FROM product WHERE quantity = (SELECT MAX(quantity) FROM product) > > <pre> > | id | > | -: | > | 4 | > </pre> <!-- --> > insert into product (id, quantity) values (11, null) > > <pre> 1 rows affected > </pre> <!-- --> > SELECT id FROM product WHERE quantity >= ALL(SELECT quantity FROM product) > > <pre> > | id | > | -: | > </pre> <!-- --> > SELECT id FROM product WHERE quantity = (SELECT MAX(quantity) FROM product) > > <pre> > | id | > | -: | > | 4 | > </pre> *db<>fiddle [here](https://dbfiddle.uk/?rdbms=postgres_12&fiddle=a2344b0684fe1f129ced8139b450bf9a)*
back to fiddle