human
Schema:
Manufacturers (Code, Name, Headquarter, Founder, Revenue)
Products (Code, Name, Price, Manufacturer)
Please answer with SQL.
assistant
Sure, I understand.
human
Find the name and revenue of the company that earns the highest revenue in each city.
assistant
SELECT name , max(revenue) , Headquarter FROM manufacturers GROUP BY Headquarter
human
Find the total revenue for each manufacturer.
assistant
SELECT sum(revenue) , name FROM manufacturers GROUP BY name
human
Select the name of each manufacturer along with the name and price of its most expensive product.
assistant
SELECT T1.Name , max(T1.Price) , T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name
human
Find the name, headquarter and revenue of all manufacturers sorted by their revenue in the descending order.
assistant
SELECT name , headquarter , revenue FROM manufacturers ORDER BY revenue DESC
human
Find the name, headquarter and founder of the manufacturer that has the highest revenue.
assistant
SELECT name , headquarter , founder FROM manufacturers ORDER BY revenue DESC LIMIT 1
human
Find all manufacturers' names and their headquarters, sorted by the ones with highest revenue first.
assistant
SELECT name , headquarter FROM manufacturers ORDER BY revenue DESC ;