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
#include <iostream> | |
#include <windows.h> | |
#include <string> | |
using namespace std; | |
// структура товарів | |
struct Product { | |
int id; | |
char name[50]; | |
float price; |
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
--1. Вивести кількість товарів кожної категорії, середня ціна поставки яких більше 100 гривень. | |
SELECT p.quantity AS [кількість товарів], | |
c.name AS [категорії товарів ] | |
FROM Product p | |
JOIN Category c ON p.id_category = c.id | |
JOIN Delivery d ON d.id_product = p.id | |
GROUP BY c.name, p.quantity | |
HAVING AVG(d.price) > 100 | |
--2. Показати категорії "Фрукти" та "Цукерки", їхні товари та загальну суму їх продажу. |
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
-- 1. Товари та виробники. | |
SELECT p.name AS [назва товару]], | |
pr.name AS [виробник] | |
FROM Product p | |
RIGHT OUTER JOIN Producer pr ON p.id_producer = pr.id | |
-- 2. Категорії без товару. | |
SELECT name | |
FROM Category | |
EXCEPT |
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
-- 1. | |
SELECT p.name AS [назва продукту], | |
c.name AS [назва категорії], | |
s.name AS [постачальник] | |
FROM Product p | |
JOIN Category c ON p.id_category = c.id | |
JOIN Delivery d ON p.id = d.id_product | |
JOIN Supplier s ON s.id = d.id_supplier | |
WHERE s.name IN ('ООО Самтаймс', 'Картофка') |
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
-- 1. | |
SELECT p.name AS [назва продукту], | |
c.name AS [назва категорії], | |
s.name AS [постачальник] | |
FROM Product p | |
JOIN Category c ON p.id_category = c.id | |
JOIN Delivery d ON p.id = d.id_product | |
JOIN Supplier s ON s.id = d.id_supplier | |
WHERE s.name IN ('ООО Самтаймс', 'Картофка') |
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
--1. Порахувати можливий дохід за хліб та молоко (з урахуванням знижок на ці товари)( якщо знижки в відсотках (наприклад 5%)- price / 1.05 * quantity ) | |
Select name, (price - discount) * quantity AS [загальна вартість] | |
FROM Product | |
WHERE name IN ('Йогурт фрукт. пак. 400г.', 'Сметана 20% пак. 200г.') | |
--2. Отримати інформацію про товари, які були доставлені вчора і сьогодні більше 10 одиниць (getdate, dateadd) | |
Select* | |
FROM Product | |
WHERE date_of_delivery IN (CAST(GETDATE() -9 AS DATE), CAST(GETDATE() -11 AS DATE)) | |
--3. Показати назви та ціни товарів, доставлених протягом останнього місяця | |
Select name, price |