Q: write query How many products are sold out in May 2018 having price more than 100.?
Ans: Here is an example of a SQL query that can be used to retrieve the number of products that were sold out in May 2018 and have a price greater than 100:
SELECT COUNT(*)
FROM orders o
JOIN products p ON o.product_id = p.product_id
WHERE o.order_date BETWEEN '2018-05-01' AND '2018-05-31'
AND p.price > 100
AND o.status = 'Sold Out';
This query retrieves the count of rows from the orders table, join it with products table using the product_id. Then it filters the results where the order_date is between '2018-05-01' and '2018-05-31' and the price in products table is more than 100 and the status of order is 'Sold Out'.
This query assumes that there are two tables: "orders" which contains columns product_id, order_date, status and "products" which contains columns product_id and price.
Please keep in mind that table names, column names and the actual query may vary depending on the database structure and naming conventions used.
No comments:
Post a Comment