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

回答編集履歴

1

改良

2017/05/26 07:51

投稿

yambejp
yambejp

スコア118110

answer CHANGED
@@ -17,4 +17,19 @@
17
17
  ) as t3 using(use_date,in_station,out_station)
18
18
  inner join ic as t4 on coalesce(id1,id0)=id
19
19
 
20
+ ```
21
+
22
+ # 改良版
23
+
24
+ ```SQL
25
+ select * from ic
26
+ where id in (
27
+ select min(id) from ic
28
+ where (use_date,in_station,out_station,is_request) in (
29
+ select use_date,in_station,out_station,max(is_request) as is_request from ic
30
+ where is_request in (0,1)
31
+ group by use_date,in_station,out_station
32
+ )
33
+ group by use_date,in_station,out_station
34
+ );
20
35
  ```