[leetcode] Count Salary Categories | 내배캠 SQL 코드카타 112
·
[TIL] SQL/SQL 코드카타
1907. Count Salary CategoriesSELECT "Low Salary" AS category, sum(income 50000) AS accounts_countFROM Accounts
[leetcode] Product Price at a Given Date | 내배캠 SQL 코드카타 110
·
[TIL] SQL/SQL 코드카타
1164. Product Price at a Given Date Write a solution to find the prices of all products on 2019-08-16.Assume the price of all products before any change is 10.Return the result table in any order. # 2019-08-16 일자 '전'의 제품 가격 찾기?# 가격 변경 전(2019-8-16 전) 가격은 모두 10으로 가정SELECT DISTINCT(P1.product_id), IFNULL(P2.new_price, 10) AS priceFROM (SELECT DISTINCT product_id FROM Products) AS P1LEFT JOIN (..
[leetcode] if문 활용 | Triangle Judgement | 내배캠 SQL 코드카타 108
·
[TIL] SQL/SQL 코드카타
610. Triangle Judgement Report for every three line segments whether they can form a triangle.Return the result table in any order.삼각형이 될 수 있는지 확인 - 가능하면 Yes, 불가능하면 No 삼각형 조건: 두 변의 길이의 합이 나머지 한 변의 길이보다 커야 함 = 모든 경우의 수를 'IF 함수'를 활용해서 확인 4-1. IF 활용 [TIL] 내배캠 SQL 2, 3주차 강의 / 1회차 LIVE SESSION 복습오늘의 한마디완벽하게 하려고 하지 말고, 일단 하고 보자.목차 1회차 LIVE SESSION 복습 SQL 2주차, 3주차 강의 복습 1회차 LIVE SESSION 복습같은 기초 SQL 강의임..
[leetcode] Consecutive Numbers: LEAD⭐, WITH절 | 내배캠 SQL 코드카타 109
·
[TIL] SQL/SQL 코드카타
최소 3번 이상 연속된 번호를 출력  연속된 번호를 확인하기 위해 LEAD 활용- 기능: 이후의 행을 가지고 올 수 있음(바로 이후, 특정 위치)- 기본 구조: LEAD(컬럼명[, 가져오고 싶은 위치, default]) OVER ([ORDER BY ~])  [SQLD:파트2-2] SQL 활용: 집합 연산자, 다중행 함수(그룹, 윈도우) | 격파르타 SQLD 자격증 챌린지 10일과목2 SQL 기본 및 활용제2장 SQL 활용 제1절 서브쿼리 제2절 집합 연산자 제3절 그룹 함수 제4절 윈도우 함수 제5절 Top N 쿼리 제6절 계층형 질의와 셀프조인 제7절 PIVOT절과 UNPIVOT 제8절 정규표zhixide.tistory.com WITH cte AS ( SELECT num, LEAD(num, ..
[leetcode] HAVING⭐, COUNT | Biggest Single Number, Customers Who Bought All Products, Primary Department for Each Employee | 내배캠 SQL 코드카타 104, 105, 107
·
[TIL] SQL/SQL 코드카타
619. Biggest Single NumberA single number is a number that appeared only once in the MyNumbers table.Find the largest single number. If there is no single number, report null.SELECT MAX(num) AS numFROM ( SELECT num FROM MyNumbers GROUP BY num HAVING COUNT(num)=1) AS single_number 오답노트-- 잠시 기억이 안 나는 바람에SELECT CASE WHEN COUNT(MAX(num))=1 THEN MAX(num) ELSE NULL END AS numFRO..
[leetcode] Product Sales Analysis | 내배캠 SQL 코드카타 101
·
[TIL] SQL/SQL 코드카타
1070. Product Sales Analysis III Write a solution to select the product id, year, quantity, and price for the first year of every product sold.Return the resulting table in any order.  (971ms): 다중(?) IN 활용SELECT product_id, year AS first_year, quantity, priceFROM SalesWHERE (product_id, year) IN (SELECT product_id, MIN(year) FROM Sales GROUP BY product_id) 성능이 훨씬 좋은 쿼리 (925ms): JOIN 활용SELECT s1...
[leetcode] Immediate Food Delivery II: 다중 IN, 서브쿼리 | 내배캠 SQL 코드카타 97
·
[TIL] SQL/SQL 코드카타
1174. Immediate Food Delivery II If the customer's preferred delivery date is the same as the order date,then the order is called immediate; otherwise, it is called scheduled. The first order of a customer is the order with the earliest order date that the customer made.It is guaranteed that a customer has precisely one first order. Write a solution to find the percentage of immediate orders in ..
[leetcode] DATE_SUB: Game Play Analysis IV, User Activity for the Past 30 Days | 내배캠 SQL 코드카타 98, 100
·
[TIL] SQL/SQL 코드카타
550. Game Play Analysis IV Write a solution to report the fraction of playersthat logged in again on the day after the day they first logged in, rounded to 2 decimal places.In other words, you need to count the number of players that logged in for at least two consecutive days starting from their first login date, then divide that number by the total number of players. 로그인한 다음 날 연속적으로 로그인한 플레이어의..
[leetcode] Monthly Transactions I | 내배캠 코드카타 96
·
[TIL] SQL/SQL 코드카타
1193. Monthly Transactions I  Write an SQL query to find for each month and country,the number of transactions and their total amount,the number of approved transactions and their total amount.Return the result table in any order.각 월별, 나라별거래 횟수, 총 거래액,승인된 거래 횟수, 그 승인된 거래의 총액을 찾는 쿼리문을 작성해라.영문 표현이 어색해서 그렇지, 그렇게 어려운 문제 아님 SELECT DATE_FORMAT(trans_date, '%Y-%m') AS `month`, #LEFT(trans_date, 7) 방법도 ..
[leetcode] Queries Quality and Percentage 해석 및 풀이 | 내배캠 SQL 코드카타 95
·
[TIL] SQL/SQL 코드카타
1211. Queries Quality and Percentage We define query quality as:The average of the ratio between query rating and its position. We also define poor query percentage as:The percentage of all queries with rating less than 3. Write a solution to find each query_name, the quality and poor_query_percentage.Both quality and poor_query_percentage should be rounded to 2 decimal places.Return the result ..
이데마
'mysql' 태그의 글 목록