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

回答編集履歴

1

追記

2016/11/01 11:49

投稿

yambejp
yambejp

スコア117946

answer CHANGED
@@ -25,4 +25,16 @@
25
25
  on t1.year=t2.year and t1.company=t2.company
26
26
  group by company;
27
27
 
28
- ```
28
+ ```
29
+
30
+ # 追記
31
+ 該当するレコードをすべてとりだすならこうしてください
32
+ ```SQL
33
+ SELECT t1.* from table_a as t1
34
+ INNER JOIN (
35
+ SELECT company,max(year) as year
36
+ from table_a where value IS NOT NULL GROUP BY company
37
+ ) as t2
38
+ on t1.year=t2.year and t1.company=t2.company
39
+ WHERE t1.company='A';
40
+ ```