|
| 1 | +# Exercise 2 |
| 2 | + |
| 3 | +## ex_1 |
| 4 | + |
| 5 | +寫出可以得到下方結果的 SQL 語句 |
| 6 | + |
| 7 | +Answer |
| 8 | + |
| 9 | +```sql |
| 10 | +/* SOME SQL STATEMENT */ |
| 11 | +``` |
| 12 | + |
| 13 | +Output |
| 14 | + |
| 15 | +``` |
| 16 | ++-----------+--------+--------------+-----------+ |
| 17 | +| member_id | member | committee_id | committee | |
| 18 | ++-----------+--------+--------------+-----------+ |
| 19 | +| 1 | John | 1 | John | |
| 20 | +| 3 | Mary | 2 | Mary | |
| 21 | +| 5 | Amelia | 3 | Amelia | |
| 22 | ++-----------+--------+--------------+-----------+ |
| 23 | +3 rows in set (0.00 sec) |
| 24 | +``` |
| 25 | + |
| 26 | +## ex_2 |
| 27 | + |
| 28 | +寫出可以得到下方結果的 SQL 語句 |
| 29 | + |
| 30 | +Answer |
| 31 | + |
| 32 | +```sql |
| 33 | +/* SOME SQL STATEMENT */ |
| 34 | +``` |
| 35 | + |
| 36 | +Output |
| 37 | + |
| 38 | +``` |
| 39 | ++-----------+--------+--------------+-----------+ |
| 40 | +| member_id | member | committee_id | committee | |
| 41 | ++-----------+--------+--------------+-----------+ |
| 42 | +| 1 | John | 1 | John | |
| 43 | +| 2 | Jane | NULL | NULL | |
| 44 | +| 3 | Mary | 2 | Mary | |
| 45 | +| 4 | David | NULL | NULL | |
| 46 | +| 5 | Amelia | 3 | Amelia | |
| 47 | ++-----------+--------+--------------+-----------+ |
| 48 | +5 rows in set (0.00 sec) |
| 49 | +``` |
| 50 | + |
| 51 | +## ex_3 |
| 52 | + |
| 53 | +寫出可以得到下方結果的 SQL 語句 |
| 54 | + |
| 55 | +Answer |
| 56 | + |
| 57 | +```sql |
| 58 | +/* SOME SQL STATEMENT */ |
| 59 | +``` |
| 60 | + |
| 61 | +Output |
| 62 | + |
| 63 | +``` |
| 64 | ++-----------+--------+--------------+-----------+ |
| 65 | +| member_id | member | committee_id | committee | |
| 66 | ++-----------+--------+--------------+-----------+ |
| 67 | +| 2 | Jane | NULL | NULL | |
| 68 | +| 4 | David | NULL | NULL | |
| 69 | ++-----------+--------+--------------+-----------+ |
| 70 | +2 rows in set (0.00 sec) |
| 71 | +``` |
| 72 | + |
| 73 | +## ex_4 |
| 74 | + |
| 75 | +寫出可以得到下方結果的 SQL 語句 |
| 76 | + |
| 77 | +Answer |
| 78 | + |
| 79 | +```sql |
| 80 | +/* SOME SQL STATEMENT */ |
| 81 | +``` |
| 82 | + |
| 83 | +Output |
| 84 | + |
| 85 | +``` |
| 86 | ++-----------+--------+--------------+-----------+ |
| 87 | +| member_id | member | committee_id | committee | |
| 88 | ++-----------+--------+--------------+-----------+ |
| 89 | +| 1 | John | 1 | John | |
| 90 | +| 3 | Mary | 2 | Mary | |
| 91 | +| 5 | Amelia | 3 | Amelia | |
| 92 | +| NULL | NULL | 4 | Joe | |
| 93 | ++-----------+--------+--------------+-----------+ |
| 94 | +4 rows in set (0.00 sec) |
| 95 | +``` |
| 96 | + |
| 97 | +## ex_5 |
| 98 | + |
| 99 | +寫出可以得到下方結果的 SQL 語句 |
| 100 | + |
| 101 | +Answer |
| 102 | + |
| 103 | +```sql |
| 104 | +/* SOME SQL STATEMENT */ |
| 105 | +``` |
| 106 | + |
| 107 | +Output |
| 108 | + |
| 109 | +``` |
| 110 | ++-----------+--------+--------------+-----------+ |
| 111 | +| member_id | member | committee_id | committee | |
| 112 | ++-----------+--------+--------------+-----------+ |
| 113 | +| NULL | NULL | 4 | Joe | |
| 114 | ++-----------+--------+--------------+-----------+ |
| 115 | +1 row in set (0.00 sec) |
| 116 | +``` |
0 commit comments