From 7b175fa90c363fbed96aa4c55593f9dbe6f03ada Mon Sep 17 00:00:00 2001
From: Andrew <saintruler@gmail.com>
Date: Tue, 14 Dec 2021 09:18:15 +0400
Subject: =?UTF-8?q?=D0=98=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=20?=
 =?UTF-8?q?=D1=87=D0=B5=D1=82=D0=B2=D1=91=D1=80=D1=82=D1=83=D1=8E=20=D0=BB?=
 =?UTF-8?q?=D0=B0=D0=B1=D1=83.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 task4_requests.sql | 26 +++++++++-----------------
 1 file changed, 9 insertions(+), 17 deletions(-)

(limited to 'task4_requests.sql')

diff --git a/task4_requests.sql b/task4_requests.sql
index fc41e5d..a7eee14 100644
--- a/task4_requests.sql
+++ b/task4_requests.sql
@@ -16,10 +16,8 @@ GO
 
 -- составной
 
-SELECT Boxes.id, Orders.id, date
-FROM Boxes JOIN Orders
-ON Boxes.order_id = Orders.id
-WHERE Boxes.warehouse_id = 12465
+SELECT id, warehouse_id FROM Boxes
+WHERE warehouse_id = 12465
 GO
 
 CREATE INDEX Boxes_Composite ON Boxes (order_id, warehouse_id);
@@ -30,11 +28,8 @@ GO
 -- покрывающий
 
 SELECT * FROM Orders
-WHERE EXISTS(
-    SELECT * FROM Customers
-    WHERE customer_id = Customers.id
-        AND Customers.email LIKE N'%@mail.ru'
-);
+WHERE date > '2021-09-04'
+GO
 
 CREATE INDEX Orders_Index_Covering ON Orders (id)
     INCLUDE (customer_id, city_id, date);
@@ -53,15 +48,12 @@ GO
 
 -- индекс с включеными столбцами
 
-SELECT date FROM Orders
-WHERE EXISTS(
-    SELECT * FROM Customers
-    WHERE customer_id = Customers.id
-        AND Customers.email LIKE N'%@mail.ru'
-);
+SELECT id, customer_id, date FROM Orders
+WHERE customer_id = 12345
+GO
 
-CREATE INDEX Orders_Index_Columns ON Orders (id)
-    INCLUDE (customer_id, date);
+CREATE INDEX Orders_Index_Columns ON Orders (customer_id)
+    INCLUDE (id, date);
 GO
 DROP INDEX Orders_Index_Columns ON Orders;
 GO
-- 
cgit v1.2.3

