File tree 2 files changed +48
-0
lines changed
2 files changed +48
-0
lines changed Original file line number Diff line number Diff line change 82
82
56 . 15 дней изучения SQL - [ 15 Days of Learning SQL] ( ./tasks/56.md )
83
83
57 . Планирование проекта SQL - [ SQL Project Planning] ( ./tasks/57.md )
84
84
58 . Места размещения - [ Placements] ( ./tasks/58.md )
85
+ 59 . Симметричные пары - [ Symmetric Pairs] ( ./tasks/59.md )
85
86
86
87
87
88
## В процессе... , будет дополнено)
Original file line number Diff line number Diff line change
1
+ ###
2
+
3
+ <img src =" ./art/59.png " alt =" solution " >
4
+
5
+ #### eng:
6
+ You are given a table, Functions, containing two columns: X and Y.
7
+
8
+ Two pairs (X1, Y1) and (X2, Y2) are said to be symmetric pairs if X1 = Y2 and X2 = Y1.
9
+
10
+ Write a query to output all such symmetric pairs in ascending order by the value of X. List the rows such that X1 ≤ Y1.
11
+
12
+
13
+ #### рус:
14
+ Вам дана таблица «Функции», содержащая два столбца: X и Y.
15
+
16
+ Две пары (X1, Y1) и (X2, Y2) называются симметричными парами, если X1 = Y2 и X2 = Y1.
17
+
18
+ Напишите запрос, чтобы вывести все такие симметричные пары в порядке возрастания значения X. Перечислите строки, такие что X1 ≤ Y1.
19
+
20
+ #### код с коментариями:
21
+ ``` sql
22
+ SELECT f1 .x , f1 .y from functions f1
23
+ INNER JOIN functions f2
24
+ WHERE (f2 .x = f1 .y )
25
+ AND (f1 .x = f2 .y )
26
+ GROUP BY f1 .x , f1 .y
27
+ HAVING ((f1 .x = f1 .y ) AND (COUNT (* ) > 1 ))
28
+ OR (f1 .x < f1 .y )
29
+ ORDER BY f1 .x ;
30
+ ```
31
+
32
+ #### код для hackerrank:
33
+ ``` sql
34
+ SELECT f1 .x , f1 .y from functions f1
35
+ INNER JOIN functions f2
36
+ WHERE (f2 .x = f1 .y )
37
+ AND (f1 .x = f2 .y )
38
+ GROUP BY f1 .x , f1 .y
39
+ HAVING ((f1 .x = f1 .y ) AND (COUNT (* ) > 1 ))
40
+ OR (f1 .x < f1 .y )
41
+ ORDER BY f1 .x ;
42
+ ```
43
+
44
+
45
+ #### На [ главную] ( https://github.com/BEPb/hackerrank_sql#readme )
46
+
47
+ ---
You can’t perform that action at this time.
0 commit comments