I want to select all the cheapest toys in my inventory, totaling $ 10.0:
That is, I want to do something similar to this:
select * from toy where sum(price) < 10.0 order by price;
What will be the correct SQL?
To make it clearer, I will add an example. Suppose I have these elements in my table:
name | price ------------------+------- car | 1 boat | 2 telephone | 8 gold bar | 50
As a result, I would: 1 car and 1 boat.
Total cost 3 USD. I canβt choose a phone because it will be $ 13, and thatβs over 10.
Any ideas?
source share