-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✏️ docs: fix typos and rearrange questions
- Loading branch information
Showing
25 changed files
with
154 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
docs/challenging-sql-problems/problems/bronze/customer-churn--sample-input.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
```sql | ||
with user_history(user_id, last_update, activity_history) as ( | ||
values | ||
(1, '2024-03-01', 81), | ||
(2, '2024-03-01', 2688), | ||
(1, '2024-03-01', 81), | ||
(2, '2024-03-01', 2688), | ||
(3, '2024-03-01', 13144) | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 4 additions & 4 deletions
8
docs/challenging-sql-problems/problems/bronze/customer-churn.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
docs/challenging-sql-problems/problems/bronze/fibonacci-sequence--sample-output.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,15 @@ | ||
```sql | ||
solution(n, f_n) as ( | ||
values | ||
(1, 1), | ||
(2, 1), | ||
(3, 2), | ||
(4, 3), | ||
(5, 5), | ||
(6, 8), | ||
(7, 13), | ||
(8, 21), | ||
(9, 34), | ||
(1, 1), | ||
(2, 1), | ||
(3, 2), | ||
(4, 3), | ||
(5, 5), | ||
(6, 8), | ||
(7, 13), | ||
(8, 21), | ||
(9, 34), | ||
(10, 55) | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 9 additions & 9 deletions
18
docs/challenging-sql-problems/problems/bronze/suspicious-login-activity--sample-input.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
```sql | ||
with events(event_id, user_id, event_datetime, event_type) as ( | ||
values | ||
(1, 1, '2024-01-01 03:00:00', 'login failed'), | ||
(2, 1, '2024-01-01 03:01:00', 'login failed'), | ||
(3, 1, '2024-01-01 03:02:00', 'login failed'), | ||
(4, 1, '2024-01-01 03:03:00', 'login failed'), | ||
(5, 1, '2024-01-01 03:04:00', 'login failed'), | ||
(6, 1, '2024-01-01 03:05:00', 'login'), | ||
(7, 2, '2024-01-01 10:00:00', 'login'), | ||
(8, 2, '2024-01-01 15:00:00', 'logout'), | ||
(9, 2, '2024-01-01 23:00:00', 'login failed') | ||
(1, 1, '2024-01-01 03:00:00', 'login failed'), | ||
(2, 1, '2024-01-01 03:01:00', 'login failed'), | ||
(3, 1, '2024-01-01 03:02:00', 'login failed'), | ||
(4, 1, '2024-01-01 03:03:00', 'login failed'), | ||
(5, 1, '2024-01-01 03:04:00', 'login failed'), | ||
(6, 1, '2024-01-01 03:05:00', 'login'), | ||
(7, 2, '2024-01-01 10:00:00', 'login'), | ||
(8, 2, '2024-01-01 15:00:00', 'logout'), | ||
(9, 2, '2024-01-01 23:00:00', 'login failed') | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 22 additions & 22 deletions
44
docs/challenging-sql-problems/problems/gold/travel-plans.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,47 @@ | ||
```sql | ||
create table routes_schedule ( | ||
schedule_id int primary key, | ||
mode_of_transport varchar not null, | ||
from_location varchar not null, | ||
to_location varchar not null, | ||
schedule_id int primary key, | ||
mode_of_transport varchar not null, | ||
from_location varchar not null, | ||
to_location varchar not null, | ||
earliest_departure timetz not null, | ||
latest_departure timetz not null, | ||
frequency time, /* `null` means that it's daily */ | ||
duration time not null, | ||
cost decimal(8, 2) not null, | ||
latest_departure timetz not null, | ||
frequency time, /* `null` means that it's daily */ | ||
duration time not null, | ||
cost decimal(8, 2) not null, | ||
); | ||
insert into routes_schedule | ||
values | ||
(1, 'train', 'London St Pancras', 'London Gatwick', '08:00:00+00:00', '20:00:00+00:00', '01:00:00', '00:30:00', 17.50), | ||
(2, 'train', 'London St Pancras', 'London Gatwick', '07:30:00+00:00', '22:30:00+00:00', '02:30:00', '01:15:00', 12.00), | ||
(3, 'bus', 'London St Pancras', 'London Gatwick', '06:15:00+00:00', '06:15:00+00:00', null, '03:30:00', 6.75), | ||
(4, 'bus', 'London St Pancras', 'London Gatwick', '19:30:00+00:00', '19:30:00+00:00', null, '03:30:00', 6.75), | ||
(3, 'bus', 'London St Pancras', 'London Gatwick', '06:15:00+00:00', '06:15:00+00:00', null, '03:30:00', 6.75), | ||
(4, 'bus', 'London St Pancras', 'London Gatwick', '19:30:00+00:00', '19:30:00+00:00', null, '03:30:00', 6.75), | ||
(5, 'train', 'London Gatwick', 'London St Pancras', '09:00:00+00:00', '21:00:00+00:00', '01:00:00', '00:30:00', 17.50), | ||
(6, 'train', 'London Gatwick', 'London St Pancras', '07:15:00+00:00', '22:15:00+00:00', '02:30:00', '01:15:00', 12.00), | ||
(7, 'bus', 'London Gatwick', 'London St Pancras', '06:00:00+00:00', '06:00:00+00:00', null, '03:30:00', 6.75), | ||
(8, 'bus', 'London Gatwick', 'London St Pancras', '20:00:00+00:00', '20:00:00+00:00', null, '03:30:00', 6.75) | ||
(7, 'bus', 'London Gatwick', 'London St Pancras', '06:00:00+00:00', '06:00:00+00:00', null, '03:30:00', 6.75), | ||
(8, 'bus', 'London Gatwick', 'London St Pancras', '20:00:00+00:00', '20:00:00+00:00', null, '03:30:00', 6.75) | ||
; | ||
create table routes_timetable ( | ||
route_id int primary key, | ||
mode_of_transport varchar not null, | ||
from_location varchar not null, | ||
to_location varchar not null, | ||
route_id int primary key, | ||
mode_of_transport varchar not null, | ||
from_location varchar not null, | ||
to_location varchar not null, | ||
departure_datetime timestamptz not null, | ||
arrival_datetime timestamptz not null, | ||
cost decimal(8, 2) not null, | ||
arrival_datetime timestamptz not null, | ||
cost decimal(8, 2) not null, | ||
); | ||
insert into routes_timetable | ||
values | ||
(1, 'boat', 'London St Pancras', 'Paris', '2024-01-01 06:00:00+00:00', '2024-01-01 07:30:00+01:00', 45.00), | ||
(1, 'boat', 'London St Pancras', 'Paris', '2024-01-01 06:00:00+00:00', '2024-01-01 07:30:00+01:00', 45.00), | ||
(2, 'plane', 'London Gatwick', 'New York', '2024-01-01 13:05:00+00:00', '2024-01-01 20:55:00-05:00', 158.00), | ||
(3, 'plane', 'London Gatwick', 'New York', '2024-01-02 20:40:00+00:00', '2024-01-03 04:30:00-05:00', 147.00), | ||
(4, 'plane', 'London St Pancras', 'Paris', '2024-01-03 07:00:00+00:00', '2024-01-03 08:30:00+01:00', 70.00), | ||
(4, 'plane', 'London St Pancras', 'Paris', '2024-01-03 07:00:00+00:00', '2024-01-03 08:30:00+01:00', 70.00), | ||
(5, 'plane', 'Paris', 'New York', '2024-01-02 12:00:00+01:00', '2024-01-02 20:30:00-05:00', 180.00), | ||
(6, 'plane', 'New York', 'London Gatwick', '2024-01-01 13:00:00-05:00', '2024-01-02 05:45:00+00:00', 160.00), | ||
(7, 'boat', 'New York', 'London Gatwick', '2024-01-01 05:30:00-05:00', '2024-01-01 23:00:00+00:00', 195.00), | ||
(8, 'boat', 'London St Pancras', 'Paris', '2024-01-01 18:00:00+00:00', '2024-01-01 19:30:00+01:00', 95.00), | ||
(9, 'boat', 'London St Pancras', 'Paris', '2024-01-02 14:00:00+00:00', '2024-01-02 15:30:00+01:00', 40.00), | ||
(8, 'boat', 'London St Pancras', 'Paris', '2024-01-01 18:00:00+00:00', '2024-01-01 19:30:00+01:00', 95.00), | ||
(9, 'boat', 'London St Pancras', 'Paris', '2024-01-02 14:00:00+00:00', '2024-01-02 15:30:00+01:00', 40.00), | ||
(10, 'plane', 'New York', 'Paris', '2024-01-01 18:00:00-05:00', '2024-01-02 17:45:00+01:00', 279.00) | ||
; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
docs/challenging-sql-problems/problems/silver/funnel-analytics--sample-output.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
```sql | ||
solution(cohort, stage, mortgages, step_rate, total_rate) as ( | ||
values | ||
('2024-01', 'full application', 1, 100, 100), | ||
('2024-01', 'decision', 1, 100, 100), | ||
('2024-01', 'documentation', 1, 100, 100), | ||
('2024-01', 'valuation inspection', 1, 100, 100), | ||
('2024-01', 'valuation made', 1, 100, 100), | ||
('2024-01', 'valuation submitted', 1, 100, 100), | ||
('2024-01', 'solicitation', 1, 100, 100), | ||
('2024-01', 'funds released', 0, 0, 0) | ||
('2024-01', 'full application', 1, 100.00, 100.00), | ||
('2024-01', 'decision', 1, 100.00, 100.00), | ||
('2024-01', 'documentation', 1, 100.00, 100.00), | ||
('2024-01', 'valuation inspection', 1, 100.00, 100.00), | ||
('2024-01', 'valuation made', 1, 100.00, 100.00), | ||
('2024-01', 'valuation submitted', 1, 100.00, 100.00), | ||
('2024-01', 'solicitation', 1, 100.00, 100.00), | ||
('2024-01', 'funds released', 0, 0.00, 0.00) | ||
) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
docs/challenging-sql-problems/problems/silver/predicting-values--sample-input.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.