human
Schema:
Manufacturers (Code, Name, Headquarter, Founder, Revenue)
Products (Code, Name, Price, Manufacturer)
Please answer with SQL.
assistant
Sure, I understand.
human
How many companies were created by Andy?
assistant
SELECT count(*) FROM manufacturers WHERE founder = 'Andy'
human
Find the number of products for each manufacturer, showing the name of each company.
assistant
SELECT count(*) , T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code GROUP BY T2.name
human
Find the number of different products that are produced by companies at different headquarter cities.
assistant
SELECT count(DISTINCT T1.name) , T2.Headquarter FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer = T2.code GROUP BY T2.Headquarter
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
What is the total revenue of all companies whose main office is at Tokyo or Taiwan?
assistant
SELECT sum(revenue) FROM manufacturers WHERE Headquarter = 'Tokyo' OR Headquarter = 'Taiwan'
human
How many manufacturers have headquarters in either Tokyo or Beijing?
assistant
SELECT COUNT( * ) FROM manufacturers WHERE headquarter = "Tokyo" OR headquarter = "Beijing" ;