SQL15 [SQL] UNION 과 UNION ALL 차이 ✅ 요약 비교표구분UNIONUNION ALL중복 제거✅ 중복 제거 (DISTINCT 자동 적용)❌ 중복 제거 안 함 (모든 행 출력)속도⏳ 상대적으로 느림 (중복 제거 연산 필요)⚡ 더 빠름 (중복 체크 안 하니까)용도결과에서 중복을 제거하고 싶을 때결과에 중복을 포함하고 싶을 때📌 예제 데이터🔹 Table AIDName1Alice2Bob🔹 Table BIDName2Bob3Carol📍 1. UNION 예시SELECT * FROM A UNION SELECT * FROM B; 🔸 결과IDName1Alice2Bob3Carol📍 2. UNION ALL 예시SELECT * FROM A UNION ALL SELECT * FROM B;🔸 결과IDName1Alice2Bob2Bob3Carol🧠 언제 어떤 .. 2025. 3. 24. [SQL] 해커랭크 HackerRank Interviews 문제 풀이 문제Samantha interviews many candidates from different colleges using coding challenges and contests. Write a query to print the contest_id, hacker_id, name, and the sums of total_submissions, total_accepted_submissions, total_views, and total_unique_views for each contest sorted by contest_id. Exclude the contest from the result if all four sums are .Note: A specific contest can be used to screen.. 2025. 3. 19. [SQL] 해커랭크 HakerRank 문제 풀이 Symmetric Pairs 문제 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. 해석주어진 테이블 **Functions**에는 두 개의 컬럼 **X**와 **Y**가 존재한다.이 테이블에서 **대칭 쌍(Symmetric Pairs)**을 찾아야 한다.두 개의 쌍 (X1, Y1)과 (X2.. 2025. 3. 17. [SQL] 해커랭크 HackerRank Placements 문제 풀이 문제You are given three tables: Students, Friends and Packages. Students contains two columns: ID and Name. Friends contains two columns: ID and Friend_ID (ID of the ONLY best friend). Packages contains two columns: ID and Salary (offered salary in $ thousands per month).Write a query to output the names of those students whose best friends got offered a higher salary than them. Names must be orde.. 2025. 3. 16. [SQL] 해커랭크 HackerRank New Companies 문제 풀이 문제Amber's conglomerate corporation just acquired some new companies. Each of the companies follows this hierarchy:Given the table schemas below, write a query to print the company_code, founder name, total number of lead managers, total number of senior managers, total number of managers, and total number of employees. Order your output by ascending company_code.Note:The tables may contain dupli.. 2025. 3. 15. [SQL] 해커랭크 HackerRank Binary Tree Nodes 문제 풀이 문제You are given a table, BST, containing two columns: N and P, where N represents the value of a node in Binary Tree, and P is the parent of N.Write a query to find the node type of Binary Tree ordered by the value of the node. Output one of the following for each node:Root: If node is root node.Leaf: If node is leaf node.Inner: If node is neither root nor leaf node. 해석주어진 테이블 BST는 이진 트리(Binary .. 2025. 3. 14. 이전 1 2 3 다음