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
app.js | |
// на выбор есть 20 заданий, необходимо выполнить любые 5 из них. | |
// очень желательно разобраться со spread, rest, closure, arrow functions, function expressions и по возможности показать это в решениях. | |
// 1. Написать функцию, которая принимает 2 числа и возвращает -1, если первое меньше чем второе, 1 — если первое больше чем второе и 0 — если числа равны. | |
function compareNumbers(a, b) { | |
if (a < b) { | |
return -1; | |
} else if (a > b) { |
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
index.html | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8" /> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |
<script type="text/javascript" src=".\\app.js"></script> |
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
--USER DEFINED FUNCTIONS: | |
--1. Написать функцию, которая покажет список всех пользовательских баз данных SQL Server, и их общие размеры в байтах | |
CREATE OR ALTER FUNCTION sizeOfBases() | |
RETURNS @listOfBases TABLE(file_name nvarchar(50), size_of_file float) | |
AS | |
BEGIN | |
INSERT @listOfBases |
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
--STORED PROCEDURES: | |
USE Warehouse | |
--1. Написать хранимую процедуру, которая показывает общее количество проданных товаров в каждой из категорий и от каждого производителя. | |
CREATE PROCEDURE ProducerCategorySaleCount AS | |
SELECT prod.name [Производитель], c.name [Категория], SUM(s.quantity) [продано товара] | |
FROM Product p | |
JOIN Sale s ON s.product_id = p.id | |
JOIN Category c ON c.id = p.category_id | |
JOIN Producer prod ON prod.id =p.producer_id | |
GROUP BY prod.name, c.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
--VARIABLES: | |
--1. Показать среднее арифметическое трёх вещественных чисел, хранящихся в переменных | |
DECLARE @var1 real = 2, @var2 real =3, @var3 real = 5 | |
PRINT (@var1 +@var2+@var3)/3 | |
--2. Показать количество цифр числа, хранящегося в переменной | |
DECLARE @value int = 12345, @result int = 0 | |
WHILE @value > 0 | |
BEGIN |
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 (в решении обязательно использовать минимум один подзапрос!): | |
USE Warehouse | |
--1. Показать самый популярный товар магазина (больше всего раз продавался) | |
SELECT p.name | |
FROM Product p | |
WHERE p.id = (SELECT TOP 1 p.id | |
FROM Product p | |
JOIN Sale s ON s.product_id=p.id | |
GROUP BY p.id ORDER BY COUNT(1) DESC) |
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. Показать товары, средняя цена продажи которых была больше 10000 | |
SELECT p.name, | |
AVG(s.price_product*s.quantity) | |
FROM Product p | |
JOIN Sale s ON p.id = s.product_id | |
GROUP BY p.name | |
HAVING AVG(s.price_product*s.quantity)>10000 | |
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
--INNER JOINS: | |
--1. Показать названия и категории товаров, поставщиками которых являются MSI или Gigabyte | |
USE Warehouse | |
SELECT p.name AS Товар, | |
c.name AS Категория, | |
pr.name AS Производитель | |
FROM Product p JOIN Category c ON p.category_id = c.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
USE [master] | |
GO | |
/****** Object: Database [Warehouse] Script Date: 08.02.2025 16:32:50 ******/ | |
CREATE DATABASE [Warehouse] | |
CONTAINMENT = NONE | |
ON PRIMARY | |
( NAME = N'Warehouse', FILENAME = N'E:\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\Warehouse.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB ) | |
LOG ON | |
( NAME = N'Warehouse_log', FILENAME = N'E:\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\Warehouse_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
-- 1. Посчитать возможную выручку за Видеокарты и ЦПУ (с учётом скидок на эти товары) | |
USE Product | |
SELECT *, (price-price*discount/100)*quantity AS [возможная выручка] | |
FROM Products | |
WHERE category IN ('GPU', 'CPU') | |
-- 2. Получить информацию о том, каких товаров вчера и сегодня доставили более 5 штук (getdate, dateadd) | |
SELECT id, name, category, date_of_delivery, quantity, producer, price | |
FROM Products | |
WHERE (date_of_delivery = CAST(GETDATE()-1 AS date) OR date_of_delivery = CAST(GETDATE() AS date)) AND quantity >= 5 |
NewerOlder