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
<!DOCTYPE html> | |
<html lang="uk"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>JS Завдання</title> | |
<style> | |
body { | |
font-family: Arial, sans-serif; | |
padding: 20px; | |
display: flex; |
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
SUBQUERIES (в решении обязательно использовать минимум один подзапрос!): | |
1. Показать самый популярный товар магазина (больше всего раз продавался) | |
SELECT p.name as Popular | |
FROM Product p | |
WHERE p.id = ( | |
SELECT TOP 1 s.id_product | |
FROM Sale s | |
GROUP BY s.id_product |
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. Написать хранимую процедуру, которая показывает общее количество проданных товаров в каждой из категорий и от каждого производителя. | |
CREATE PROCEDURE task1_1 | |
AS | |
BEGIN | |
SELECT c.name , pr.name , SUM(s.quantity) | |
FROM Sale s | |
JOIN Product p ON s.id_product = p.id | |
JOIN Category c ON p.id_category = c.id | |
JOIN Producer pr ON p.id_producer = pr.id |
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
VARIABLES: | |
1. Показать количество цифр числа, хранящегося в переменной | |
DECLARE @Number INT = 1234567 | |
PRINT LEN(CAST(@Number AS VARCHAR)) | |
2. Показать горизонтальную линию из звёздочек длиной @L |
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 Товар | |
FROM Sale s | |
INNER JOIN Product p ON s.id_product = p.id | |
GROUP BY p.name | |
HAVING AVG(s.price) > 50 | |
2 | |
SELECT c.name AS Категория, COUNT(p.id) AS Количество_товаров, AVG(d.price) AS Средняя_цена_поставки | |
FROM Product p |
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, c.name | |
FROM Product p | |
INNER JOIN Category c ON p.id_category = c.id | |
INNER JOIN Delivery d ON p.id = d.id_product | |
INNER JOIN Supplier s ON d.id_supplier = s.id | |
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 SUM((price - (price * discount / 100)) * quantity) | |
FROM Product | |
WHERE name IN ('Хлеб', 'Молоко') | |
2. Получить информацию о том, каких товаров вчера и сегодня доставили более 10 штук (getdate, dateadd) | |
SELECT name , quantity, date_of_delivery | |
FROM Product |
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 [master] | |
GO | |
/****** Object: Database [Store] Script Date: 12.02.2025 19:23:35 ******/ | |
CREATE DATABASE [Store] | |
CONTAINMENT = NONE | |
ON PRIMARY | |
( NAME = N'Store', FILENAME = N'D:\Course\SQL\SqlDev\MSSQL16.MSSQLSERVER\MSSQL\DATA\Store.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB ) | |
LOG ON | |
( NAME = N'Store_log', FILENAME = N'D:\Course\SQL\SqlDev\MSSQL16.MSSQLSERVER\MSSQL\DATA\Store_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB ) | |
WITH CATALOG_COLLATION = DATABASE_DEFAULT, LEDGER = OFF |
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 [master] | |
GO | |
/****** Object: Database [Store] Script Date: 04.02.2025 3:22:26 ******/ | |
CREATE DATABASE [Store] | |
CONTAINMENT = NONE | |
ON PRIMARY | |
( NAME = N'Store', FILENAME = N'D:\Course\SQL\SqlDev\MSSQL16.MSSQLSERVER\MSSQL\DATA\Store.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB ) | |
LOG ON | |
( NAME = N'Store_log', FILENAME = N'D:\Course\SQL\SqlDev\MSSQL16.MSSQLSERVER\MSSQL\DATA\Store_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB ) | |
WITH CATALOG_COLLATION = DATABASE_DEFAULT, LEDGER = OFF |