728x90

Data & BI/SQL Coding Test 6

[LeetCode](중급) 178. Lank Score (MS SQL)

문제Column NameTypeidintscoredecimalid is the primary key (column with unique values) for this table.Each row of this table contains the score of a game. Score is a floating point value with two decimal places. score 별 rank 를 매기고 각 score 별 순위를 score 별 내림차순으로 출력해라. 풀이SELECT A.score, R.idx as rank FROM Scores ALEFT OUTER JOIN (SELECT score, ROW_NUMBER() OVER (ORDER BY score DESC) AS idx FROM Scores ..

[LeetCode](중급) 176. Second Highest Salary

문제Column NameTypeidintsalaryint[Table : Employee]id is the primary key (column with unique values) for this table.Each row of this table contains information about the salary of an employee. Write a solution to find the second highest distinct salary from the Employee table. If there is no second highest salary, return null 주어진 Employee 테이블에서 두 번째로 높은 급여를 조회해라. 두 번째 급여가 없다면 null을 조회해라. 풀이SELECT..

[LeetCode](초급) 182. Duplicate Emails

문제Column NameTypeidintemailvarchar[Table : Person]id is the primary key (column with unique values) for this table.Each row of this table contains an email. The emails will not contain uppercase letters. Write a solution to report all the duplicate emails. Note that it's guaranteed that the email field is not NULL.주어진 테이블에서 중복된 이메일을 출력해라. 풀이SELECT DISTINCT(ABC.email)FROM (SELECT email, COUNT..

728x90