Skip to content

Commit

Permalink
Merge pull request #70 from traPtitech/fix_section4
Browse files Browse the repository at this point in the history
section4
  • Loading branch information
ikura-hamu authored Jun 15, 2023
2 parents bf6e274 + 552031f commit dd4d20f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 34 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,12 @@ https://vitepress.dev/guide/markdown
- warning: 注意事項(気をつけないと正常に実行できないことがあるもの)
- danger: 破壊的な事象(サーバーに負荷を与える操作など)
- 練習問題は heading で区切って、container は使用しない
- 答えを載せる場合は details を使用して隠す
- 答えを載せる場合は details を使用して隠す

## 使用しているポート

| 用途 | ポート番号 |
| -------------- | ---------- |
| フロントエンド | 5173 |
| バックエンド | 8080 |
| Adminer | 8081 |
2 changes: 1 addition & 1 deletion docs/chapter1/section4/1_sql.md
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ https://dev.mysql.com/doc/refman/8.0/ja/delete.html

Adminer(https://www.adminer.org/) はデータベースを GUI(マウスなど)を使って操作するためのソフトウェアです。traP 内では traQ の開発などで使われています。同じようなソフトウェアとして phpMyAdmin などがあります。これらを使うことで SQL を使わなくてもデータベースを操作できます。

今回は`task up`を実行したときに Adminer が立ち上がるようになっています。ブラウザで <a href='http://localhost:8080/' target="_blank" rel="noopener noreferrer">localhost:8080</a> にアクセスすると使えます。
今回は`task up`を実行したときに Adminer が立ち上がるようになっています。ブラウザで <a href='http://localhost:8081/' target="_blank" rel="noopener noreferrer">localhost:8081</a> にアクセスすると使えます。
ログイン画面が出てくるはずなので、MySQL にログインするときと同様に、下の画像のように入力してログインしてください。パスワードは`password`です。

![](images/adminer_login.png)
Expand Down
64 changes: 32 additions & 32 deletions docs/chapter1/section4/2_sql_exercise.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,32 +366,32 @@ SELECT country.Name, city.Name FROM country LEFT JOIN city ON country.Code = cit

### 2-2

`country`テーブルから、人口の多い順に順位(`Rank`)、国名、人口を取得してください。
`country`テーブルから、人口の多い順に順位(`Ranking`)、国名、人口を取得してください。

:::details 答え

```sql
SELECT RANK() OVER (ORDER BY Population DESC) AS Rank, Name, Population FROM country LIMIT 10;
SELECT RANK() OVER (ORDER BY Population DESC) AS Ranking, Name, Population FROM country LIMIT 10;
```

**出力**

```txt
+------+--------------------+------------+
| Rank | Name | Population |
+------+--------------------+------------+
| 1 | China | 1277558000 |
| 2 | India | 1013662000 |
| 3 | United States | 278357000 |
| 4 | Indonesia | 212107000 |
| 5 | Brazil | 170115000 |
| 6 | Pakistan | 156483000 |
| 7 | Russian Federation | 146934000 |
| 8 | Bangladesh | 129155000 |
| 9 | Japan | 126714000 |
| 10 | Nigeria | 111506000 |
+------+--------------------+------------+
10 rows in set (0.00 sec)
+---------+--------------------+------------+
| Ranking | Name | Population |
+---------+--------------------+------------+
| 1 | China | 1277558000 |
| 2 | India | 1013662000 |
| 3 | United States | 278357000 |
| 4 | Indonesia | 212107000 |
| 5 | Brazil | 170115000 |
| 6 | Pakistan | 156483000 |
| 7 | Russian Federation | 146934000 |
| 8 | Bangladesh | 129155000 |
| 9 | Japan | 126714000 |
| 10 | Nigeria | 111506000 |
+---------+--------------------+------------+
10 rows in set (0.01 sec)
```

`Rank()`は Window 関数と呼ばれるものの 1 つで、 MySQL では 8.0 から使えるようになりました。
Expand Down Expand Up @@ -443,21 +443,21 @@ ORDER BY Speakers DESC LIMIT 10;
**出力**

```txt
+------+------------+------------------+
| Rank | Language | Speakers |
+------+------------+------------------+
| 1 | Chinese | 1191843539.22187 |
| 2 | Hindi | 405633085.47466 |
| 3 | Spanish | 355029461.90782 |
| 4 | English | 347077860.65105 |
| 5 | Arabic | 233839240.44018 |
| 6 | Bengali | 209304713.12510 |
| 7 | Portuguese | 177595269.43999 |
| 8 | Russian | 160807559.89702 |
| 9 | Japanese | 126814106.08493 |
| 10 | Punjabi | 104025371.70681 |
+------+------------+------------------+
10 rows in set (0.02 sec)
+---------+------------+------------------+
| Ranking | Language | Speakers |
+---------+------------+------------------+
| 1 | Chinese | 1191843539.22187 |
| 2 | Hindi | 405633085.47466 |
| 3 | Spanish | 355029461.90782 |
| 4 | English | 347077860.65105 |
| 5 | Arabic | 233839240.44018 |
| 6 | Bengali | 209304713.12510 |
| 7 | Portuguese | 177595269.43999 |
| 8 | Russian | 160807559.89702 |
| 9 | Japanese | 126814106.08493 |
| 10 | Punjabi | 104025371.70681 |
+---------+------------+------------------+
10 rows in set (0.01 sec)
```

割合を掛けているため、人数に小数が出てきます。
Expand Down
Binary file modified docs/chapter1/section4/images/postman.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit dd4d20f

Please sign in to comment.