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, 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 total revenue for each manufacturer.
assistant
SELECT sum(revenue) , name FROM manufacturers GROUP BY name
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
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
What are the average, maximum and total revenues of all companies?
assistant
SELECT avg(revenue) , max(revenue) , sum(revenue) FROM manufacturers
human
What are the names of manufacturers with revenue greater than the average of all revenues?
assistant
SELECT name FROM manufacturers WHERE revenue > ( SELECT avg ( revenue ) FROM manufacturers ) ;