human
Schema:
phone (Name, Phone_ID, Memory_in_G, Carrier, Price)
market (Market_ID, District, Num_of_employees, Num_of_shops, Ranking)
phone_market (Market_ID, Phone_ID, Num_of_stock)
Please answer with SQL.
assistant
Sure, I understand.
human
State the phone name which has the least price on the list?
assistant
SELECT Name FROM phone AS T2 ORDER BY price ASC LIMIT 1;
human
Which phone id has the highest stock on the list?
assistant
SELECT phone_id FROM phone_market ORDER BY num_of_stock DESC LIMIT 1;
human
For each phone, show its names and total number of stocks?
assistant
SELECT T2.Name , SUM( T1.Num_of_stock ) FROM phone_market AS T1 JOIN phone AS T2 ON T1.Phone_ID = T2.Phone_ID GROUP BY T2.Name ;