코테 준비 | Draw The Triangle 1/Draw The Triangle 2 (SET @ / REPEAT)
·
SQL
Draw The Triangle 1 | HackerRankDraw the triangle pattern using asterisks.www.hackerrank.com☑️  Draw The Triangle 1[문제]'*' 특수문자 반복하여 직각 삼각형 구현하는 문제[문제 풀이]내 코드 SELECT REPEAT('* ',20) UNION ALL SELECT REPEAT('* ',19) UNION ALL SELECT REPEAT('* ',18) UNION ALL SELECT REPEAT('* ',17) UNION ALL SELECT REPEAT('* ',16) UNION ALL SELECT REPEAT('* ',15) UNION ALL SELECT REPEAT('* ',14)UNION ALL SELECT RE..
코테준비 | 해커랭크 interviews (다중 테이블 join)
·
SQL
Interviews | HackerRankfind total number of view, total number of unique views, total number of submissions and total number of accepted submissions.www.hackerrank.com☑️  interviews[문제]Samantha interviews many candidates from different colleges using coding challenges and contests. Write a query to print the contest_id, hacker_id, name, and the sums of total_submissions, total_accepted_submissio..
코테준비 | 해커랭크 SQL Project Planning / Placements (연속된 그룹 필터링/다중 JOIN)
·
SQL
SQL Project Planning | HackerRankWrite a query to output the start and end dates of projects listed by the number of days it took to complete the project in ascending order.www.hackerrank.com  Placements | HackerRankWrite a query to output the names of those students whose best friends got offered a higher salary than them.www.hackerrank.com ☑️  SQL Project Planning[문제]If the End_Date of the tas..
코테준비 | hackerrank - Challenges (다중컬럼 서브쿼리,CTE)
·
SQL
Challenges | HackerRankPrint the total number of challenges created by hackers.www.hackerrank.com☑️  Challenges[문제]Julia asked her students to create some coding challenges. Write a query to print the hacker_id, name, and the total number of challenges created by each student. Sort your results by the total number of challenges in descending order. If more than one student created the same numbe..
코테준비 | Second Highest Salary (의도적으로 null 값 출력하기)
·
SQL
☑️  176. Second Highest Salary[문제]Write a solution to find the second highest distinct salary from the Employee table. If there is no second highest salary, return null (return None in Pandas).두번째로 높은 연봉자 조회하기, 없다면 null 로 반환[문제 풀이]내 코드 - window & with 문WITH dnkt AS (SELECT * ,DENSE_RANK() OVER (ORDER BY salary DESC) as dnk ,count(id) OVER () AS total_cntsFROM employee), nullt AS (SELEC..
QCC | 4회차 코드 리뷰 & 피드백
·
SQL
☑️  문제 1. 지역별 매출이 가장 높은 매장의 지역 조회[문제]지역별로 매출이 가장 높은 매장의 매출을 조회하는 SQL 문을 작성해주세요단, 해당 지역에 매장이 두 개 이상인 경우만 결과에 포함해주세요. 결과는 지역 이름을 기준으로 오름차순으로 정렬해주세요.[문제 풀이]내 코드 SELECT REGION_NAME AS region_name ,MAX(SALES) AS highest_salesFROM stores WHERE REGION_NAME IN (SELECT REGION_NAME FROM stores s GROUP BY REGION_NAME HAVING COUNT(DISTINCT STORE_ID) >=2)GROUP BY REGION_NAMEORDER BY REGION_NA..
코테 준비 | Group Sold Products By The Date(group_concat)
·
SQL
☑️  1484. Group Sold Products By The Date[문제]Write a solution to find for each date the number of different products sold and their names.Return the result table ordered by sell_date.The sold products names for each date should be sorted lexicographically.날짜별 팔린 제품 갯수 집계 및 팔린 제품명 한 컬럼에 기재 [문제 풀이]내 코드 → 끝까지 못 품 (실패)WITH rownt AS (SELECT sell_date ,product ,ROW_NUMBER() OVER (PARTITION ..
코테준비 | Patients With a Condition (문자열 추출 - 정규표현식 REGEXP , 특정문자기준 슬라이싱 - SUBSTRING_INDEX)
·
SQL
☑️  Patients With a Condition[문제]Write a solution to find the patient_id, patient_name, and conditions of the patients who have Type I Diabetes. Type I Diabetes always starts with DIAB1 prefix.'DIAB1' 가 접두사인 값 모두 출력 [문제 풀이]코드1 - LIKESELECT *FROM PATIENTS WHERE conditions LIKE 'DIAB1%' OR conditions LIKE '% DIAB1% 코드2 - REGEXP SELECT *FROM PATIENTS WHERE conditions REGEXP '^DIAB1' OR conditi..
QCC | 3회차 코드 리뷰 & 피드백
·
SQL
☑️  문제1:  첫 주문 고객 연도별 매출 조회 [문제] “2011년 12월”에 첫 주문을 한 고객들의 연도별 매출을 조회하는 SQL 문을 작성하세요. 고객 이름은 이름과 성을 결합하여 생성합니다. 결과는 고객 ID(customerid)기준 오름차순, 연도(year) 기준 오름차순으로 정렬합니다.[문제 풀이]내 코드 SELECT so.customerid ,concat(c.firstname," ",c.lastname) AS customer_name ,year(so.orderdate) AS 'year' ,round(sum(so.orderqty*so.unitprice),2) AS gmvFROM sales_order so INNER JOIN customer c ON so.customerid = c..
코테 준비 | Friend Requests II: Who Has the Most Friends / Investments in 2016 (union all / 중복값만 or 중복값이 아닌 행만 필터링 하기)
·
SQL
☑️  602. Friend Requests II: Who Has the Most Friends[문제]Write a solution to find the people who have the most friends and the most friends number.The test cases are generated so that only one person has the most friends.가장 많은 친구를 가진 사람과 그 수 조회하기[문제 풀이]내 코드 WITH total AS ( SELECT requester_id as id ,count(distinct accepter_id) as n FROM REQUESTACCEPTED GROUP BY requester_id UNIO..