Analysis/SQL5 [MySQL] LeetCode - Game Play Analysis I Table 'Activity' Question Write a solution to find the first login date for each player. 각 플레이어들의 첫 로그인 날짜를 구해달라는 문제! 바로 윈도우 함수가 떠오르는 문제이다. Answer #1 대신 윈도우 함수에 쓰이는 집계함수가 다양하게 있는데, 난 가장 먼저 LAG가 떠올랐다. 만약 플레이어별로 날짜에 따라 나열을 한 다음 이전 활동 날짜를 확인가능하다면 첫 로그인이 아닌 날짜,이전 활동 날짜가 확인불가하다면 첫 로그인 날짜로 골라낼 수 있다. SELECT player_id, event_date AS first_loginFROM ( SELECT * , LAG (event_date, 1) OVER.. 2024. 5. 1. [MySQL] Hackerrank - Olivander's Inventory Table 'Wands' Table 'Wands_property' - SubDomain: Basic Join Question Hermione decides the best way to choose is by determining the minimum number of gold galleons needed to buy each non-evil wand of high power and age. Write a query to print the id, age, coins_needed, and power of the wands that Ron's interested in, sorted in order of descending power. If more than one wand has same power, sort.. 2024. 3. 22. [MySQL] HackerRank - The Report Table 'Students' FieldTypeIDIntegerNAMEStringMARKSInteger Table 'Grades' FieldTypeGRADEStringMIN_MARKStringMAX_MARKString - The Report - SubDomain: Basic Join Question 조건이 꽤나 많은데 정리하자면 다음과 같다 1) Grade < 8 인 학생은 이름도 누락시키기 (;;) 2) Grade는 높은 사람들부터, 동일 등급이면 Name 기준 알파벳 순으로 3) Grade < 8 인 학생은 Name 기준으로 나열 불가하니 Marks 낮은 사람들부터 복잡한 문제는 Input/Output 예시도 주는 멋진 문제은행! 다만 문제는 Input에 Grade 정보가 없어 멋진 join을 기대하.. 2024. 3. 13. 이전 1 2 다음