SQL/MySQL

·SQL/MySQL
https://school.programmers.co.kr/learn/courses/30/lessons/131533 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr -- 코드를 입력하세요 SELECT product_code, sum(sales_amount) * price AS "SALES" FROM PRODUCT LEFT JOIN OFFLINE_SALE ON PRODUCT.PRODUCT_ID = OFFLINE_SALE.PRODUCT_ID GROUP BY PRODUCT_CODE ORDER BY SALES DESC, product_code 기본적인 JOIN문제..
·SQL/MySQL
https://school.programmers.co.kr/learn/courses/30/lessons/151138 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr -- 코드를 입력하세요 SELECT HISTORY_ID,CAR_ID, DATE_FORMAT(START_DATE,"%Y-%m-%d") AS START_DATE, DATE_FORMAT(END_DATE,"%Y-%m-%d") AS END_DATE, ( CASE WHEN DATEDIFF(END_DATE,START_DATE) + 1 >= 30 THEN "장기 대여" ELSE "단기 대여" END ) AS ..
·SQL/MySQL
https://school.programmers.co.kr/learn/courses/30/lessons/164672 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr -- 코드를 입력하세요 SELECT BOARD_ID,WRITER_ID,TITLE,PRICE, ( CASE WHEN STATUS = "DONE" THEN "거래완료" WHEN STATUS = "SALE" THEN "판매중" ELSE "예약중" END ) AS "STATUS" FROM USED_GOODS_BOARD WHERE CREATED_DATE = "2022-10-05" ORDER BY BOAR..
·SQL/MySQL
기본구조 CREATE FUNCTION 'function name' ('parameter name', 'datatype') RETURNS 'datatype' (DETERMINSTIC) BEGIN DECLARE 'varialbe name' 'datatype'; SET ; RETURN (Query) / 'variable name'; END 사용방법 SELECT 'function name' (parameter) 예제 문제 Table: Employee +-------------+------+ | Column Name | Type | +-------------+------+ | id | int | | ..
·SQL/MySQL
문제 Table: Employee +--------------+---------+ | Column Name | Type | +--------------+---------+ | id | int | | name | varchar | | salary | int | | departmentId | int | +--------------+---------+ id is the primary key column for this table. departmentId is a foreign key of the ID from the Department table. Each row of this table indicates the ID, name, and salary of an employee. It also contains ..
·SQL/MySQL
문제 Table: Logs +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | num | varchar | +-------------+---------+ id is the primary key for this table. Write an SQL query to find all numbers that appear at least three times consecutively. Return the result table in any order. The query result format is in the following example. Example 1: Input: Logs table: +----..
·SQL/MySQL
기본 틀 함수(컬럼) OVER (PARTITION BY 컬럼 ORDER BY 컬럼) PARTITION BY는 기존에 배운 GROUP BY랑 비슷한 원리라 생각하면 편하다. 집계 함수 (AVG,MIN,MAX,COUNT,SUM 등) MAX(컬럼) OVER (PARTITION BY 컬럼) Employee table id Name Salary DepartmentId MaxSalary 1 Joe 70000 1 90000 2 Jim 90000 1 90000 3 Henry 80000 2 80000 4 Sam 60000 2 80000 5 Max 90000 1 90000 예시 코드 SELECT id, Name, Salary, DepartmentId, Max(Salary) OVER (PARTITION BY Departme..
·SQL/MySQL
문제설명 Table: Logs +-------------+---------+ | Column Name | Type | +-------------+---------+ | id | int | | num | varchar | +-------------+---------+ id is the primary key for this table. Write an SQL query to find all numbers that appear at least three times consecutively. Return the result table in any order. The query result format is in the following example. Example 1: Input: Logs table: +--..
·SQL/MySQL
You are given two tables: Students and Grades. Students contains three columns ID, Name and Marks. Grades contains the following data: 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. ..
Shine_sunho
'SQL/MySQL' 카테고리의 글 목록