human
Schema:
Manufacturers (Code, Name, Headquarter, Founder, Revenue)
Products (Code, Name, Price, Manufacturer)
Please answer with SQL.
assistant
Sure, I understand.
human
Compute the average price of all the products.
assistant
SELECT avg(price) FROM products
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
Find all information of all the products with a price between $60 and $120.
assistant
SELECT * FROM products WHERE price BETWEEN 60 AND 120
human
Select the name of the products with a price less than or equal to $200.
assistant
SELECT name FROM products WHERE price <= 200
human
Select the name and price of all products with a price larger than or equal to $180, and sort first by price (in descending order), and then by name (in ascending order).
assistant
SELECT name , price FROM products WHERE price >= 180 ORDER BY price DESC , name ASC
human
Compute the number of products with a price larger than or equal to $180.
assistant
SELECT COUNT( * ) FROM products WHERE price >= 180 ;