본문 바로가기

MySQL/문제풀이24

[LeetCode] 182. Duplicate Emails 1. 문제 Write a SQL query to find all duplicate emails in a table named Person. +----+---------+ | Id | Email | +----+---------+ | 1 | a@b.com | | 2 | c@d.com | | 3 | a@b.com | +----+---------+ For example, your query should return the following for the above table: +---------+ | Email | +---------+ | a@b.com | +---------+ Note: All emails are in lowercase. 2. 답 SELECT Email FROM Person GrOUP BY E.. 2021. 3. 22.
[LeetCode] 620. Not Boring Movies 1. 문제 X city opened a new cinema, many people would like to go to this cinema. The cinema also gives out a poster indicating the movies’ ratings and descriptions. Please write a SQL query to output movies with an odd numbered ID and a description that is not 'boring'. Order the result by rating. For example, table cinema: +---------+-----------+--------------+-----------+ | id | movie | descript.. 2021. 3. 22.
[LeetCode] 595. Big Countries 1. 문제 There is a table World +-----------------+------------+------------+--------------+---------------+ | name | continent | area | population | gdp | +-----------------+------------+------------+--------------+---------------+ | Afghanistan | Asia | 652230 | 25500100 | 20343000 | | Albania | Europe | 28748 | 2831741 | 12960000 | | Algeria | Africa | 2381741 | 37100000 | 188681000 | | Andorra .. 2021. 3. 22.
[LeetCode] CASE 테이블 피봇 : 1179. Reformat Department Table 1. 문제 Table: Department +---------------+---------+ | Column Name | Type | +---------------+---------+ | id | int | | revenue | int | | month | varchar | +---------------+---------+ (id, month) is the primary key of this table. The table has information about the revenue of each department per month. The month has values in ["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec".. 2021. 3. 15.
[HackerRank] Self JOIN: Symmetric Pairs 1. 문제 You are given a table, Functions, containing two columns: X and Y. Two pairs (X1, Y1) and (X2, Y2) are said to be symmetric pairs if X1 = Y2 and X2 = Y1. Write a query to output all such symmetric pairs in ascending order by the value of X. List the rows such that X1 ≤ Y1. Sample Input Sample Output 20 20 20 21 22 23 2. 답 SELECT x, y FROM functions WHERE x = y GROUP BY x, y HAVING count(*).. 2021. 3. 15.
[LeetCode] Self JOIN : 197. Rising Temperature 1. 문제 Table: Weather +---------------+---------+ | Column Name | Type | +---------------+---------+ | id | int | | recordDate | date | | temperature | int | +---------------+---------+ id is the primary key for this table. This table contains information about the temperature in a certain day. Write an SQL query to find all dates' id with higher temperature compared to its previous dates (yester.. 2021. 3. 15.