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
//----------------------------------------111 1 | |
const comparaison = (a, b) => { | |
if (a < b) return -1; | |
if (a > b) return 1; | |
return 0; | |
} | |
//-----------------------------------------222 3 | |
const stringSum = (...numbers) => numbers.reduce((a, x) => a + x, 0).toString(); |
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
//------------------ 111 | |
// let input = prompt("Input number: "); | |
// let number = Number(input); | |
// | |
// if (isNaN(number)) | |
// { | |
// alert("Please enter a number"); | |
// } |
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 FUNCTION dbo.GetServers() | |
RETURNS TABLE | |
AS | |
RETURN | |
( | |
SELECT | |
d.name AS БД, |
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 ShowAll | |
AS | |
BEGIN | |
SELECT s.quantity AS [Кол-во], | |
c.name AS Категория, | |
pr.name AS Производитель | |
FROM Sale s | |
JOIN Product p ON s.id_product = p.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
-- 1 | |
DECLARE @a SMALLINT = 1 | |
DECLARE @b SMALLINT = 2 | |
DECLARE @c SMALLINT = 3 | |
PRINT (@a + @b + @c) / 3 | |
-- 2 | |
DECLARE @var SMALLINT = 123 |
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 Продукт, | |
SUM(s.quantity) AS [Кол-во продаж] | |
FROM Product p | |
JOIN Sale s ON p.id = id_product | |
GROUP BY p.name | |
HAVING SUM(s.quantity) = | |
(SELECT MAX(total_sales) | |
FROM ( | |
SELECT SUM(quantity) AS total_sales) |
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 Название товара, | |
AVG(p.price) AS Цена | |
FROM Product p | |
GROUP BY p.name | |
HAVING AVG(p.price) > 50 | |
-- 2 | |
SELECT p.c AS Категория, | |
AVG(COUNT(p.id)) AS [Количество товаров] |
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 Категория, | |
pr.name AS Производитель | |
FROM Product p | |
JOIN Category c ON p.id_category = c.id | |
JOIN Producer pr ON p.id_producer = pr.id | |
WHERE pr.name = 'Bavaria Milk' OR pr.name = 'Sakura Foods' | |
-- 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
USE [master] | |
GO | |
/****** Object: Database [Store] Script Date: 09.02.2025 17:20:51 ******/ | |
CREATE DATABASE [Store] | |
CONTAINMENT = NONE | |
ON PRIMARY | |
( NAME = N'Store', FILENAME = N'C:\DataBaseMB\Store.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB ) | |
LOG ON | |
( NAME = N'Store_log', FILENAME = N'C:\DataBaseMB\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
-- 1 | |
SELECT *, price * quantity - discount AS [revenue] | |
FROM Product | |
WHERE category = 'Bakery' OR category = 'Dairy' | |
-- 2 | |
SELECT * | |
FROM Product | |
WHERE discount >= 10 AND date_of_delivery BETWEEN DATEADD(DAY, -1, GETDATE()) AND GETDATE() |
NewerOlder