Show the names of phones and their stocks.
select t2.name, t1.num_of_stock from phone_market as t1 join phone as t2 on t1.phone_id = t2.phone_id
Of those, which have 64 GB memory?
select t2.name, t1.num_of_stock from phone_market as t1 join phone as t2 on t1.phone_id = t2.phone_id where t2.memory_in_g = 64
How about the having total stocks at least 2000 instead?
select t2.name, t1.num_of_stock from phone_market as t1 join phone as t2 on t1.phone_id = t2.phone_id group by t2.name having sum(t1.num_of_stock) >= 2000
Don't show their number of stocks.
select t2.name from phone_market as t1 join phone as t2 on t1.phone_id = t2.phone_id group by t2.name having sum(t1.num_of_stock) >= 2000
Can you sort them in increasing order of total stocks?
select t2.name from phone_market as t1 join phone as t2 on t1.phone_id = t2.phone_id group by t2.name having sum(t1.num_of_stock) >= 2000 order by sum(t1.num_of_stock)
Decreasing order instead.
select t2.name from phone_market as t1 join phone as t2 on t1.phone_id = t2.phone_id group by t2.name having sum(t1.num_of_stock) >= 2000 order by sum(t1.num_of_stock) desc