본문 바로가기

SQL

(22)
(SQL) - LeetCode (easy) 1075. Project Employees I https://leetcode.com/problems/project-employees-i/description/ Project Employees I - LeetCode Can you solve this real interview question? Project Employees I - Table: Project +-------------+---------+ | Column Name | Type | +-------------+---------+ | project_id | int | | employee_id | int | +-------------+---------+ (project_id, employee_id) is th leetcode.com 집계함수와 join을 사용해보는 문제였습니다. 📕 풀이방법 📔..
(SQL) - LeetCode (easy) 627. Swap Salary https://leetcode.com/problems/swap-salary/description/ Swap Salary - LeetCode Can you solve this real interview question? Swap Salary - Table: Salary +-------------+----------+ | Column Name | Type | +-------------+----------+ | id | int | | name | varchar | | sex | ENUM | | salary | int | +-------------+----------+ id is the primar leetcode.com update문에 case when절을 사용해본 문제였습니다. 📕 풀이방법 📔 풀이과정 성별..
(SQL) - LeetCode (easy) 619. Biggest Single Number https://leetcode.com/problems/biggest-single-number/description/ Biggest Single Number - LeetCode Can you solve this real interview question? Biggest Single Number - Table: MyNumbers +-------------+------+ | Column Name | Type | +-------------+------+ | num | int | +-------------+------+ There is no primary key for this table. It may contain duplicates leetcode.com group by와 sub query를 사용해본 문제였습..
(SQL) - LeetCode (easy) 595. Big Countries https://leetcode.com/problems/big-countries/description/ Big Countries - LeetCode Can you solve this real interview question? Big Countries - Table: World +-------------+---------+ | Column Name | Type | +-------------+---------+ | name | varchar | | continent | varchar | | area | int | | population | int | | gdp | bigint | +----------- leetcode.com where을 사용해본 문제였습니다. 📕 풀이방법 📔 풀이과정 정해진 조건에 해당하는..
(SQL) - LeetCode (easy) 584. Find Customer Referee https://leetcode.com/problems/find-customer-referee/description/ Find Customer Referee - LeetCode Can you solve this real interview question? Find Customer Referee - Table: Customer +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | name | varchar | | referee_id | int | +-------------+---------+ id is the primary leetcode.com select from where절을 사용해보는 기본 문제..
(SQL) - LeetCode (easy) 577. Employee Bonus https://leetcode.com/problems/employee-bonus/description/ Employee Bonus - LeetCode Can you solve this real interview question? Employee Bonus - Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com outer join을 사용해보는 문제였습니다. 📕 풀이방법 📔 풀이과정 1. 서로 다른 table인 Employee에서 Bonus table을 left outer join 해줍..
(SQL) - LeetCode (easy) 511. Game Play Analysis I https://leetcode.com/problems/game-play-analysis-i/description/ Game Play Analysis I - LeetCode Can you solve this real interview question? Game Play Analysis I - Table: Activity +--------------+---------+ | Column Name | Type | +--------------+---------+ | player_id | int | | device_id | int | | event_date | date | | games_played | int | +---------- leetcode.com group by를 사용해보는 문제였습니다. 📕 풀이방법 📔..
(Tibero7) - auto increment 처럼 sequence 사용하기 🍳머리말 tibero는 auto increment와 비슷하게 동작하는 sequence를 지원합니다. 📕 예제1 📔 schema 📑 sequence 생성 CREATE SEQUENCE TEST_SEQ; 📑 table 생성 CREATE TABLE TEST ( ID NUMBER DEFAULT TEST_SEQ.NEXTVAL PRIMARY KEY, name varchar(255) ); 📑 data 삽입 ID의 default값이 seq.nextval이므로 insert into문에서 column을 명시하지 않아도 자동으로 nextval이 들어갑니다. INSERT INTO test(name) values('why?'); 📑 확인 SELECT * FROM test 📑 되지 않는 경우 default 값을 ddl에 명시 하지..