Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b782b28

Browse files
committed
Update: column name
1 parent 46ff015 commit b782b28

File tree

4 files changed

+58
-61
lines changed

4 files changed

+58
-61
lines changed

‎problems/human-traffic-of-stadium/README.md

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,14 @@
1111

1212
## 601. Human Traffic of Stadium (Hard)
1313

14-
<p>X city built a new stadium, each day many people visit it and the stats are saved as these columns: <b>id</b>, <b>date</b>, <b>people</b>
15-
</p><p>
16-
Please write a query to display the records which have 3 or more consecutive rows and the amount of people more than 100(inclusive).
17-
</p>
18-
14+
<p>X city built a new stadium, each day many people visit it and the stats are saved as these columns: <b>id</b>, <strong>visit_</strong><b>date</b>, <b>people</b></p>
15+
16+
<p>Please write a query to display the records which have 3 or more consecutive rows and the amount of people more than 100(inclusive).</p>
1917
For example, the table <code>stadium</code>:
18+
2019
<pre>
2120
+------+------------+-----------+
22-
| id | date | people |
21+
| id | visit_date | people |
2322
+------+------------+-----------+
2423
| 1 | 2017年01月01日 | 10 |
2524
| 2 | 2017年01月02日 | 109 |
@@ -31,20 +30,19 @@ For example, the table <code>stadium</code>:
3130
| 8 | 2017年01月08日 | 188 |
3231
+------+------------+-----------+
3332
</pre>
34-
<p>
35-
For the sample data above, the output is:
36-
</p>
33+
34+
<p>For the sample data above, the output is:</p>
35+
3736
<pre>
3837
+------+------------+-----------+
39-
| id | date | people |
38+
| id | visit_date | people |
4039
+------+------------+-----------+
4140
| 5 | 2017年01月05日 | 145 |
4241
| 6 | 2017年01月06日 | 1455 |
4342
| 7 | 2017年01月07日 | 199 |
4443
| 8 | 2017年01月08日 | 188 |
4544
+------+------------+-----------+
4645
</pre>
47-
<p>
48-
<b>Note:</b><br/>
49-
Each day only have one row record, and the dates are increasing with id increasing.
50-
</p>
46+
47+
<p><b>Note:</b><br />
48+
Each day only have one row record, and the dates are increasing with id increasing.</p>
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
Create table If Not Exists stadium (id int, date DATE NULL, people int);
1+
Create table If Not Exists stadium (id int, visit_date DATE NULL, people int);
22
Truncate table stadium;
3-
insert into stadium (id, date, people) values ('1', '2017年01月01日', '10');
4-
insert into stadium (id, date, people) values ('2', '2017年01月02日', '109');
5-
insert into stadium (id, date, people) values ('3', '2017年01月03日', '150');
6-
insert into stadium (id, date, people) values ('4', '2017年01月04日', '99');
7-
insert into stadium (id, date, people) values ('5', '2017年01月05日', '145');
8-
insert into stadium (id, date, people) values ('6', '2017年01月06日', '1455');
9-
insert into stadium (id, date, people) values ('7', '2017年01月07日', '199');
10-
insert into stadium (id, date, people) values ('8', '2017年01月08日', '188');
3+
insert into stadium (id, visit_date, people) values ('1', '2017年01月01日', '10');
4+
insert into stadium (id, visit_date, people) values ('2', '2017年01月02日', '109');
5+
insert into stadium (id, visit_date, people) values ('3', '2017年01月03日', '150');
6+
insert into stadium (id, visit_date, people) values ('4', '2017年01月04日', '99');
7+
insert into stadium (id, visit_date, people) values ('5', '2017年01月05日', '145');
8+
insert into stadium (id, visit_date, people) values ('6', '2017年01月06日', '1455');
9+
insert into stadium (id, visit_date, people) values ('7', '2017年01月07日', '199');
10+
insert into stadium (id, visit_date, people) values ('8', '2017年01月08日', '188');

‎problems/sales-person/README.md

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
## 607. Sales Person (Easy)
1313

1414
<p><b>Description</b></p>
15-
<p>
16-
Given three tables: <code>salesperson</code>, <code>company</code>, <code>orders</code>.</br>
17-
Output all the <b>names</b> in the table <code>salesperson</code>, who didnt have sales to company 'RED'.
18-
<p>
19-
<b>Example</b><br />
20-
<b>Input</b>
21-
<p>
22-
Table: <code>salesperson</code>
23-
</p>
15+
16+
<p>Given three tables: <code>salesperson</code>, <code>company</code>, <code>orders</code>.<br />
17+
Output all the <b>names</b> in the table <code>salesperson</code>, who didn&rsquo;t have sales to company &#39;RED&#39;.</p>
18+
19+
<p><b>Example</b><br />
20+
<b>Input</b></p>
21+
22+
<p>Table: <code>salesperson</code></p>
23+
2424
<pre>
2525
+----------+------+--------+-----------------+-----------+
2626
| sales_id | name | salary | commission_rate | hire_date |
@@ -32,10 +32,10 @@ Table: <code>salesperson</code>
3232
| 5 | Alex | 50000 | 10 | 2/3/2007 |
3333
+----------+------+--------+-----------------+-----------+
3434
</pre>
35-
The table <code>salesperson</code> holds the salesperson information. Every salesperson has a <b>sales_id</b> and a <b>name</b>.</br>
36-
<p>
37-
Table: <code>company</code>
38-
</p>
35+
The table <code>salesperson</code> holds the salesperson information. Every salesperson has a <b>sales_id</b> and a <b>name</b>.
36+
37+
<p>Table: <code>company</code></p>
38+
3939
<pre>
4040
+---------+--------+------------+
4141
| com_id | name | city |
@@ -46,25 +46,24 @@ Table: <code>company</code>
4646
| 4 | GREEN | Austin |
4747
+---------+--------+------------+
4848
</pre>
49-
The table <code>company</code> holds the company information. Every company has a <b>com_id</b> and a <b>name</b>.</br>
50-
<p>
51-
Table: <code>orders</code>
52-
</p>
49+
The table <code>company</code> holds the company information. Every company has a <b>com_id</b> and a <b>name</b>.
50+
51+
<p>Table: <code>orders</code></p>
52+
5353
<pre>
54-
+----------+----------+---------+----------+--------+
55-
| order_id | date | com_id | sales_id | amount |
56-
+----------+----------+---------+----------+--------+
57-
| 1 | 1/1/2014 | 3 | 4 | 100000 |
58-
| 2 | 2/1/2014 | 4 | 5 | 5000 |
59-
| 3 | 3/1/2014 | 1 | 1 | 50000 |
60-
| 4 | 4/1/2014 | 1 | 4 | 25000 |
54+
+----------+------------+---------+----------+--------+
55+
| order_id | order_date | com_id | sales_id | amount |
56+
+----------+------------+---------+----------+--------+
57+
| 1 | 1/1/2014 | 3 | 4 | 100000 |
58+
| 2 | 2/1/2014 | 4 | 5 | 5000 |
59+
| 3 | 3/1/2014 | 1 | 1 | 50000 |
60+
| 4 | 4/1/2014 | 1 | 4 | 25000 |
6161
+----------+----------+---------+----------+--------+
6262
</pre>
63-
The table <code>orders</code> holds the sales record information, salesperson and customer company are represented by <b>sales_id</b> and <b>com_id</b>.</br>
63+
The table <code>orders</code> holds the sales record information, salesperson and customer company are represented by <b>sales_id</b> and <b>com_id</b>.
64+
65+
<p><b>output</b></p>
6466

65-
<p>
66-
<b>output</b>
67-
</p>
6867
<pre>
6968
+------+
7069
| name |
@@ -74,11 +73,11 @@ The table <code>orders</code> holds the sales record information, salesperson an
7473
| Alex |
7574
+------+
7675
</pre>
77-
<p>
78-
<b>Explanation</b>
79-
<p>
80-
According to order '3' and '4' in table <code>orders</code>, it is easy to tell only salesperson 'John' and 'Alex' have sales to company 'RED',</br>so we need to output all the other <b>names</b> in table <code>salesperson</code>.
81-
</p>
76+
77+
<p><b>Explanation</b></p>
78+
79+
<p>According to order &#39;3&#39; and &#39;4&#39; in table <code>orders</code>, it is easy to tell only salesperson &#39;John&#39; and &#39;Alex&#39; have sales to company &#39;RED&#39;,<br />
80+
so we need to output all the other <b>names</b> in table <code>salesperson</code>.</p>
8281

8382
### Hints
8483
<details>

‎problems/sales-person/mysql_schemas.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Create table If Not Exists salesperson (sales_id int, name varchar(255), salary int,commission_rate int, hire_date varchar(255));
22
Create table If Not Exists company (com_id int, name varchar(255), city varchar(255));
3-
Create table If Not Exists orders (order_id int, date varchar(255), com_id int, sales_id int, amount int);
3+
Create table If Not Exists orders (order_id int, order_date varchar(255), com_id int, sales_id int, amount int);
44
Truncate table salesperson;
55
insert into salesperson (sales_id, name, salary, commission_rate, hire_date) values ('1', 'John', '100000', '6', '4/1/2006');
66
insert into salesperson (sales_id, name, salary, commission_rate, hire_date) values ('2', 'Amy', '12000', '5', '5/1/2010');
@@ -13,7 +13,7 @@ insert into company (com_id, name, city) values ('2', 'ORANGE', 'New York');
1313
insert into company (com_id, name, city) values ('3', 'YELLOW', 'Boston');
1414
insert into company (com_id, name, city) values ('4', 'GREEN', 'Austin');
1515
Truncate table orders;
16-
insert into orders (order_id, date, com_id, sales_id, amount) values ('1', '1/1/2014', '3', '4', '10000');
17-
insert into orders (order_id, date, com_id, sales_id, amount) values ('2', '2/1/2014', '4', '5', '5000');
18-
insert into orders (order_id, date, com_id, sales_id, amount) values ('3', '3/1/2014', '1', '1', '50000');
19-
insert into orders (order_id, date, com_id, sales_id, amount) values ('4', '4/1/2014', '1', '4', '25000');
16+
insert into orders (order_id, order_date, com_id, sales_id, amount) values ('1', '1/1/2014', '3', '4', '10000');
17+
insert into orders (order_id, order_date, com_id, sales_id, amount) values ('2', '2/1/2014', '4', '5', '5000');
18+
insert into orders (order_id, order_date, com_id, sales_id, amount) values ('3', '3/1/2014', '1', '1', '50000');
19+
insert into orders (order_id, order_date, com_id, sales_id, amount) values ('4', '4/1/2014', '1', '4', '25000');

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /