문제 입력 코드SELECT user_id, CONCAT(UPPER(LEFT(name, 1)), LCASE(SUBSTRING(name, 2))) AS nameFROM UsersORDER BY user_idSELECT user_id, CONCAT(UPPER(SUBSTRING(name, 1, 1)), LOWER(SUBSTRING(name, 2))) AS nameFROM UsersORDER BY user_idSELECT user_id, CONCAT(UPPER(SUBSTR(name, 1, 1)), LOWER(RIGHT(name, LENGTH(name)-1))) AS nameFROM UsersORDER BY user_id 코드 설명#SELECT #CONCAT #UPPER ..
문제 입력 코드1. SUBQUERYSELECT d.name AS Department, e.name AS Employee, e.salary AS SalaryFROM Employee AS eJOIN Department AS dON e.departmentId = d.idWHERE 3 > (SELECT COUNT(DISTINCT e2.salary) FROM Employee AS e2 WHERE e2.salary > e.salary AND e.departmentId = e2.departmentId) 2. WINDOW 함수 - DENSE_RANK()SELECT Department, Employee, SalaryFROM (SELECT d.name AS D..
문제 입력 코드SELECT ROUND(SUM(TIV_2016),2) AS tiv_2016FROM insuranceWHERE tiv_2015 IN (SELECT tiv_2015 FROM insurance GROUP BY tiv_2015 HAVING COUNT(pid) > 1) AND (lat, lon) IN (SELECT lat, lon FROM insurance GROUP BY lat, lon HAVING COUNT(pid) = 1); 코드 설명#SELECT #ROUND #SUM #GROUP BY #HAVING #COUNT #IN 문제 출처https://leetcode.com/problems/investments-in-2..
문제 입력 코드1. (SELECT name AS resultsFROM MovieRating JOIN Users USING(user_id)GROUP BY nameORDER BY COUNT(*) DESC, nameLIMIT 1)UNION ALL(SELECT title AS resultsFROM MovieRating JOIN Movies USING(movie_id)WHERE EXTRACT(YEAR_MONTH FROM created_at) = 202002GROUP BY titleORDER BY AVG(rating) DESC, titleLIMIT 1); 2. WITH TheMostActiveUser AS ( SELECT name FROM Users NATURAL JOIN ..