일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- Sigmoid
- skip-gram
- 프로그래머스
- hash
- sort
- 신경망
- Numpy
- MySQL
- 파이썬
- 자연어처리
- FullyConnectedLayer
- CBOW
- DeepLearning
- select
- algorithm
- que
- SQL
- kakao
- Word2vec
- Heap
- backward
- Programmers
- dl
- Python
- boj
- Stack
- stak
- 딥러닝
- PPMI
- affine
Archives
- Today
- Total
혜온의 이것저것
[HackerRank] Symmetric Paris (MySQL) 본문
https://www.hackerrank.com/challenges/symmetric-pairs/problem?isFullScreen=true
Symmetric Pairs | HackerRank
Write a query to output all symmetric pairs in ascending order by the value of X.
www.hackerrank.com
문제
You are given a table, Functions, containing two columns: X and Y.

Two pairs (X1, Y1) and (X2, Y2) are said to be symmetric pairs if X1 = Y2 and X2 = Y1.
Write a query to output all such symmetric pairs in ascending order by the value of X. List the rows such that X1 ≤ Y1.
Sample Input

Sample Output
20 20
20 21
22 23
풀이
select sub.x, sub.y
from (select if(x<=y,x,y) x, if(x<=y,y,x) y
from functions) sub
group by sub.x, sub.y
having count(*)>=2
order by sub.x
'Data Analysis > SQL' 카테고리의 다른 글
[Programmers] SQL 고득점 kit select - 과일로 만든 아이스크림 고르기 (MySQL) (0) | 2023.04.04 |
---|---|
[HackerRank] Interviews (MySQL) (0) | 2022.09.23 |
[HackerRank] Placements (MySQL) (0) | 2022.09.22 |
[HackerRank] SQL Project Planning (MySQL) (0) | 2022.09.13 |
[HackerRank] Contest Leaderboard (MySQL) (0) | 2022.09.08 |