Could you give me the names of all phones?
select distinct ( name ) from phone
How about only the phones with more than 2000 units in stock?
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
Great! Can you put them in descending order of total number of stock?
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