8000 added database support · mzpbvsig/leetcode@92562b3 · GitHub
[go: up one dir, main page]

Skip to content

Commit 92562b3

Browse files
changong(龚澄)haoel
authored andcommitted
added database support
1 parent b4b73ec commit 92562b3

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

database/README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
### LeetCode Database
2+
3+
4+
| # | Title | Solution | Difficulty |
5+
|---| ----- | -------- | ---------- |
6+
|1|[Trips and Users](https://leetcode.com/problems/trips-and-users/)| [MySQL](./TripsAndUsers.sql)|Hard|

database/TripsAndUsers.sql

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
SELECT t.`Request_at` AS Day,
2+
ROUND(COUNT(CASE WHEN t.`Status` = 'cancelled_by_driver' OR t.`Status` = 'cancelled_by_client' THEN 1 END) / COUNT(*), 2) AS "Cancellation Rate"
3+
FROM Trips t
4+
INNER JOIN Users u
5+
ON t.Client_Id = u.Users_Id
6+
WHERE u.Banned = 'No'
7+
AND t.Request_at >= '2013-10-01'
8+
AND t.Request_at <= '2013-10-03'
9+
GROUP BY t.Request_at

0 commit comments

Comments
 (0)
0