teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

3

修正3

2016/10/18 02:37

投稿

moonphase
moonphase

スコア6621

answer CHANGED
@@ -7,6 +7,7 @@
7
7
  見やすくしてみました。
8
8
 
9
9
  ※以下修正しました11:30
10
+ もう一度修正しました11:36
10
11
  ```
11
12
  select
12
13
  case
@@ -16,7 +17,7 @@
16
17
  when age between 40 and 49 then 40
17
18
  when age between 50 and 59 then 50
18
19
  else '定年'
19
- end as '世代',
20
+ end as `世代`,
20
- count(*) as '人数'
21
+ count(*) as `人数`
21
22
  from (select year(curdate()) - year(birthday) - (right(curdate(),5) < right(birthday,5)) as age from emp3) t1 group by `世代`;
22
23
  ```

2

修正2

2016/10/18 02:37

投稿

moonphase
moonphase

スコア6621

answer CHANGED
@@ -6,6 +6,7 @@
6
6
  以下追記
7
7
  見やすくしてみました。
8
8
 
9
+ ※以下修正しました11:30
9
10
  ```
10
11
  select
11
12
  case
@@ -17,5 +18,5 @@
17
18
  else '定年'
18
19
  end as '世代',
19
20
  count(*) as '人数'
20
- from (select year(curdate()) - year(birthday) - (right(curdate(),5) < right(birthday,5)) as age from emp3) t1 group by '世代';
21
+ from (select year(curdate()) - year(birthday) - (right(curdate(),5) < right(birthday,5)) as age from emp3) t1 group by `世代`;
21
22
  ```

1

追記

2016/10/18 02:30

投稿

moonphase
moonphase

スコア6621

answer CHANGED
@@ -1,4 +1,21 @@
1
1
  `year(curdate()) - year(birthday) ) - ( right(curdate(),5) < right(birthday,5) )`
2
2
  ではなく
3
3
  `year(curdate()) - year(birthday) - ( right(curdate(),5) < right(birthday,5) )`
4
- ではないですか?括弧が多い気がします。
4
+ ではないですか?括弧が多い気がします。
5
+
6
+ 以下追記
7
+ 見やすくしてみました。
8
+
9
+ ```
10
+ select
11
+ case
12
+ when age between 10 and 19 then 10
13
+ when age between 20 and 29 then 20
14
+ when age between 30 and 39 then 30
15
+ when age between 40 and 49 then 40
16
+ when age between 50 and 59 then 50
17
+ else '定年'
18
+ end as '世代',
19
+ count(*) as '人数'
20
+ from (select year(curdate()) - year(birthday) - (right(curdate(),5) < right(birthday,5)) as age from emp3) t1 group by '世代';
21
+ ```