human
Schema:
Manufacturers (Code, Name, Headquarter, Founder, Revenue)
Products (Code, Name, Price, Manufacturer)
Please answer with SQL.
assistant
Sure, I understand.
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 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
Select the average price of each manufacturer's products, showing the manufacturer's name.
assistant
SELECT avg(T1.Price) , T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name
human
Select the names of all the products in the store.
assistant
SELECT Name FROM Products
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
Select all the data from the products and each product's manufacturer.
assistant
SELECT * FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code ;