-
-
Save prodevo/4c4759acb4793d9a49d8e1b9b595716b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE Store | |
SELECT Category.name, COUNT(Product.id) AS product_count | |
FROM Product | |
INNER JOIN Category | |
ON Product.id_category = Category.id | |
INNER JOIN Delivery | |
ON Product.id = Delivery.id_product | |
GROUP BY Category.name | |
HAVING AVG(Delivery.price) > 100 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE Store | |
SELECT Category.name, product.name, SUM(Sale.price) AS price | |
FROM Product | |
INNER JOIN Category | |
ON Product.id_category = Category.id | |
INNER JOIN Sale | |
ON Product.id = Sale.id_product | |
WHERE Category.name = 'Фрукти' OR Category.name = 'Цукерки' | |
GROUP BY Category.name, Product.name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE Store | |
SELECT Category.name, MIN(Product.quantity) AS quantity | |
FROM Product | |
INNER JOIN Category | |
ON Product.id_category = Category.id | |
GROUP BY Category.name | |
ORDER BY MIN(Product.quantity) | |
--прогуглив та знайшов для повного виконання завдання максимум таке: SELECT VALUE p FROM AdventureWorksEntities.Products AS p ORDER BY p.ListPrice LIMIT(@limit) | |
--але такий синтаксис чомусь не спрацював |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE Store | |
SELECT Category.name, Product.quantity | |
FROM Product | |
INNER JOIN Category | |
ON Product.id_category = Category.id | |
INNER JOIN Delivery | |
ON Delivery.id_product = Product.id | |
INNER JOIN Supplier | |
ON Delivery.id_supplier = Supplier.id | |
WHERE Delivery.price > 400 | |
AND Supplier.id = 1 OR Supplier.id = 2 OR Supplier.id = 3 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment