File tree Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Expand file tree Collapse file tree 2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ Write a SQL query to find all duplicate emails in a table named ` Person ` .
2
+
3
+ ```
4
+ +----+---------+
5
+ | Id | Email |
6
+ +----+---------+
7
+ | 1 | a@b.com |
8
+ | 2 | c@d.com |
9
+ | 3 | a@b.com |
10
+ +----+---------+
11
+ ```
12
+ For example, your query should return the following for the above table:
13
+ ```
14
+ +---------+
15
+ | Email |
16
+ +---------+
17
+ | a@b.com |
18
+ +---------+
19
+ ```
20
+ Note: All emails are in lowercase.
21
+
22
+ ** SQL**
23
+ ```
24
+ # Write your MySQL query statement below
25
+ select email from Person
26
+ group by Email having count(*)>1
27
+ ```
Original file line number Diff line number Diff line change
1
+ Given a ` Weather ` table, write a SQL query to find all dates' Ids with higher temperature compared to its previous (yesterday's) dates.
2
+
3
+ ```
4
+ +---------+------------+------------------+
5
+ | Id(INT) | Date(DATE) | Temperature(INT) |
6
+ +---------+------------+------------------+
7
+ | 1 | 2015-01-01 | 10 |
8
+ | 2 | 2015-01-02 | 25 |
9
+ | 3 | 2015-01-03 | 20 |
10
+ | 4 | 2015-01-04 | 30 |
11
+ +---------+------------+------------------+
12
+ ```
13
+ For example, return the following Ids for the above Weather table:
14
+
15
+ ```
16
+ +----+
17
+ | Id |
18
+ +----+
19
+ | 2 |
20
+ | 4 |
21
+ +----+
22
+ ```
23
+ ** SQL**
24
+ ```
25
+ # Write your MySQL query statement below
26
+ SELECT wt1.Id
27
+ FROM Weather wt1,Weather wt2
28
+ WHERE TO_DAYS(wt1.DATE)-TO_DAYS(wt2.DATE)=1
29
+ && wt1.Temperature>wt2.Temperature;
30
+ ```
You can’t perform that action at this time.
0 commit comments