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 GetBookBorrowCount AS | |
| BEGIN | |
| SELECT g.name AS GroupName, | |
| COUNT(sc.id_book) AS BookCount | |
| FROM [Group] g | |
| LEFT JOIN Student st | |
| ON g.id = st.id_group |
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 GetBookBorrowCount AS | |
| BEGIN | |
| SELECT g.name AS GroupName, | |
| COUNT(sc.id_book) AS BookCount | |
| FROM [Group] g | |
| LEFT JOIN Student st | |
| ON g.id = st.id_group |
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 | |
| FROM Product p | |
| JOIN Sale s ON p.id = s.id_product | |
| GROUP BY p.name | |
| HAVING SUM(s.quantity) = ( | |
| SELECT MAX(Total_Sales) | |
| FROM (SELECT SUM(quantity) AS Total_Sales | |
| FROM Sale |
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 [Prod_Name], | |
| pr.name [Producer_Name] | |
| FROM Product p RIGHT JOIN Producer pr | |
| ON pr.id = p.id_producer | |
| 2. | |
| SELECT c.name [Category_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
| 1. | |
| SELECT Product.name AS Product_Name, Category.name AS Category_Name | |
| FROM Product Product | |
| JOIN Category Category ON Product.id_category = Category.id | |
| JOIN Delivery Delivery ON Product.id = Delivery.id_product | |
| JOIN Supplier Supplier ON Delivery.id_supplier = Supplier.id | |
| WHERE Supplier.name IN ('Love Water', 'Тропичный рай ООО') | |
| 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
| TASK 1 | |
| SELECT | |
| category, | |
| name, | |
| price, | |
| quantity, | |
| discounts, | |
| price * quantity * (100 - discounts) / 100.0 AS [Общая сумма со скидкой] | |
| 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 [Kino] Script Date: 19.07.2024 13:37:51 ******/ | |
| CREATE DATABASE [Kino] | |
| CONTAINMENT = NONE | |
| ON PRIMARY | |
| ( NAME = N'Kino', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\Kino.mdf' , SIZE = 8192KB , MAXSIZE = UNLIMITED, FILEGROWTH = 65536KB ) | |
| LOG ON | |
| ( NAME = N'Kino_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\Kino_log.ldf' , SIZE = 8192KB , MAXSIZE = 2048GB , FILEGROWTH = 65536KB ) | |
| WITH CATALOG_COLLATION = DATABASE_DEFAULT, LEDGER = OFF |