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
Select the average price of each manufacturer's products, showing only the manufacturer's code.
assistant
SELECT AVG(Price) , Manufacturer FROM Products GROUP BY Manufacturer
human
Compute the average price of all products with manufacturer code equal to 2.
assistant
SELECT avg(price) FROM products WHERE Manufacturer = 2
human
Select the names of manufacturer whose products have an average price higher than or equal to $150.
assistant
SELECT avg(T1.Price) , T2.name FROM products AS T1 JOIN Manufacturers AS T2 ON T1.manufacturer = T2.code GROUP BY T2.name HAVING avg(T1.price) >= 150
human
Compute the average price of all the products.
assistant
SELECT avg(price) FROM products
human
What are the average prices of products, grouped by manufacturer 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 ;