Database: manufactory_1

Question: What are the average, maximum and total revenues of all companies?
SQL: SELECT avg(revenue) ,  max(revenue) ,  sum(revenue) FROM manufacturers

Question: Find the number of manufactures that are based in Tokyo or Beijing.
SQL: SELECT count(*) FROM manufacturers WHERE headquarter  =  'Tokyo' OR headquarter  =  'Beijing'

Question: Find the founder of the company whose name begins with the letter 'S'.
SQL: SELECT founder FROM manufacturers WHERE name LIKE 'S%'

Question: What is the total revenue of all companies whose main office is at Tokyo or Taiwan?
SQL: SELECT sum(revenue) FROM manufacturers WHERE Headquarter  =  'Tokyo' OR Headquarter  =  'Taiwan'

Question: Find the name of product that is produced by both companies Creative Labs and Sony.
SQL: SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer  =  T2.code WHERE T2.name  =  'Creative Labs' INTERSECT SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer  =  T2.code WHERE T2.name  =  'Sony'

Question: Find the name, headquarter and founder of the manufacturer that has the highest revenue.
SQL: SELECT name,  headquarter,  founder FROM manufacturers ORDER BY revenue DESC LIMIT 1

Question: Find the name of companies whose revenue is greater than the average revenue of all companies.
SQL: SELECT name FROM manufacturers WHERE revenue  >  (SELECT avg(revenue) FROM manufacturers)

Question: Find the name of companies whose revenue is smaller than the revenue of all companies based in Austin.
SQL: SELECT name FROM manufacturers WHERE revenue  <  (SELECT min(revenue) FROM manufacturers WHERE headquarter  =  'Austin')

Question: Find the total revenue of companies whose revenue is larger than the revenue of some companies based in Austin.
SQL: SELECT sum(revenue) FROM manufacturers WHERE revenue  >  (SELECT min(revenue) FROM manufacturers WHERE headquarter  =  'Austin')

Question: Find the average prices of all products from each manufacture, and list each company's name.
SQL: SELECT avg(T1.price),  T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer  =  T2.code GROUP BY T2.name

Question: Find the number of different products that are produced by companies at different headquarter cities.
SQL: SELECT count(DISTINCT T1.name),  T2.Headquarter FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer  =  T2.code GROUP BY T2.Headquarter

Question: Find number of products which Sony does not make.
SQL: SELECT count(DISTINCT name) FROM products WHERE name NOT IN (SELECT T1.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer  =  T2.code WHERE T2.name  =  'Sony')

Question: Find the name of companies that do not make DVD drive.
SQL: SELECT name FROM manufacturers EXCEPT SELECT T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer  =  T2.code WHERE T1.name  =  'DVD drive'

Question: Find the number of products for each manufacturer, showing the name of each company.
SQL: SELECT count(*) ,  T2.name FROM products AS T1 JOIN manufacturers AS T2 ON T1.Manufacturer  =  T2.code GROUP BY T2.name