본문 바로가기

join

(3)
LeetCode로 공부하기180. Consecutive Numbers Table: Logs +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | num | varchar | +-------------+---------+ In SQL, id is the primary key for this table. id is an autoincrement column. Find all numbers that appear at least three times consecutively. Return the result table in any order. The result format is in the following example. Example 1: Input: Logs tabl..
HackerRank로 SQL 공부하기 - The Report 1. Students 와 Grades를 between을 사용하여 조인한다. 2. 8등급보다 낮은 등급을 받은 학생들의 이름은 null 사용한다. 3. 높은 등급 순으로 정렬한다. 혹시 같은 등급이 있다면 이름을 알파벳 순서로 정렬한다. null 인 이름이 있는 것은 학년별로 내림차순한다. 만약 그들에게 같은 등급(1-7)을 받은 학생이 둘 이상 있다면, 그 학생들의 marks 를 기준으로 오름차순으로 정렬한다. 1. Students 와 Grades를 between을 사용하여 조인한다. select * from students as s join grades as g on s.marks between g.min_mark and g.max_mark 2. 8등급보다 낮은 등급을 받은 학생들의 이름은 null 사..
LeetCode 로 공부하기 184. Department Highest Salary Table: Employee +--------------+---------+ | Column Name | Type | +--------------+---------+ | id | int | | name | varchar | | salary | int | | departmentId | int | +--------------+---------+ id is the primary key (column with unique values) for this table. departmentId is a foreign key (reference columns) of the ID from the Department table. Each row of this table indicates the ID, name, and sa..