해커랭크6 [HackerRank] Symmetric Pairs 문제 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. * Join문을 활용해서 구할 수 있는 문제이다. 실행 코드 1) X!=Y, 즉 X INNER JOIN으로 짝 구하기 2) X=Y 인 케이스 -> HAVING COUNT(*) >= 2 조건을 추가해서 짝 구하기 두 가지 케이스를 UNION으로 합쳐주면 간단하게 풀 수 있다. 2023. 3. 17. [HackerRank] New Companies 문제 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. 실행 코드 5개의 테이블을 LEFT JOIN으로 줄줄이 연결해주면 된다. 2023. 3. 14. [HackerRank] Placements 문제 Write a query to output the names of those students whose best friends got offered a higher salary than them. Names must be ordered by the salary amount offered to the best friends. It is guaranteed that no two students got same salary offer. * 실행 코드 3개의 테이블이 제시되어 있는데, 먼저 본인을 기준으로 연봉 테이블을 구해준 뒤, 본인의 친구 기준으로 연봉 테이블을 연결해주어야 한다. 나는 from절에서 서브쿼리를 사용해서 조건을 추가했다. 1. 서브쿼리를 통해 본인의 연봉 제시 2. 본 쿼리에서 'IN.. 2023. 3. 13. [HackerRank] Top Competitors 문제 Julia just finished conducting a coding contest, and she needs your help assembling the leaderboard! Write a query to print the respective hacker_id and name of hackers who achieved full scores for more than one challenge. Order your output in descending order by the total number of challenges in which the hacker earned a full score. If more than one hacker received full scores in same number.. 2023. 3. 11. [HackerRank] The Report You are given two tables: Students and Grades. Students contains three columns ID, Name and Marks. Ketty gives Eve a task to generate a report containing three columns: Name, Grade and Mark. Ketty doesn't want the NAMES of those students who received a grade lower than 8. The report must be in descending order by grade -- i.e. higher grades are entered first. If there is more than one student wi.. 2023. 2. 15. [HackerRank] Occupations, The PADS. 문제 풀이 (MySQL) Occupations The first column is an alphabetically ordered list of Doctor names. The second column is an alphabetically ordered list of Professor names. The third column is an alphabetically ordered list of Singer names. The fourth column is an alphabetically ordered list of Actor names. The empty cell data for columns with less than the maximum number of names per occupation (in this case, the P.. 2023. 2. 6. 이전 1 다음