質問編集履歴

4

クエリ編集

2021/01/15 02:40

投稿

aheshiyu_tt
aheshiyu_tt

スコア11

test CHANGED
File without changes
test CHANGED
@@ -172,13 +172,13 @@
172
172
 
173
173
 
174
174
 
175
- insert into tbl_a (d, val, dt) values ("2019-05-23", 30, "2019-05-22 03:00:00");
175
+ insert into tbl_c (d, val, dt) values ("2019-05-23", 30, "2019-05-22 03:00:00");
176
176
 
177
- insert into tbl_a (d, val, dt) values ("2019-05-23", 31, "2019-05-22 04:00:00");
177
+ insert into tbl_c (d, val, dt) values ("2019-05-23", 31, "2019-05-22 04:00:00");
178
178
 
179
- insert into tbl_a (d, val, dt) values ("2019-05-23", 32, "2019-05-22 05:00:00");
179
+ insert into tbl_c (d, val, dt) values ("2019-05-23", 32, "2019-05-22 05:00:00");
180
180
 
181
- insert into tbl_a (d, val, dt) values ("2019-05-23", 33, "2019-05-22 06:00:00");
181
+ insert into tbl_c (d, val, dt) values ("2019-05-23", 33, "2019-05-22 06:00:00");
182
182
 
183
183
  ```
184
184
 

3

クエリ編集

2021/01/15 02:40

投稿

aheshiyu_tt
aheshiyu_tt

スコア11

test CHANGED
File without changes
test CHANGED
@@ -124,61 +124,61 @@
124
124
 
125
125
  ```
126
126
 
127
- create table table_a (d date, val int, dt datetime);
127
+ create table tbl_a (d date, val int, dt datetime);
128
128
 
129
- create table table_b (d date, val int, dt datetime);
129
+ create table tbl_b (d date, val int, dt datetime);
130
130
 
131
- create table table_c (d date, val int, dt datetime);
131
+ create table tbl_c (d date, val int, dt datetime);
132
132
 
133
133
 
134
134
 
135
- insert into table_a (d, val, dt) values ("2019-05-23", 10, "2019-05-22 00:00:00");
135
+ insert into tbl_a (d, val, dt) values ("2019-05-23", 10, "2019-05-22 00:00:00");
136
136
 
137
- insert into table_a (d, val, dt) values ("2019-05-23", 11, "2019-05-22 01:00:00");
137
+ insert into tbl_a (d, val, dt) values ("2019-05-23", 11, "2019-05-22 01:00:00");
138
138
 
139
- insert into table_a (d, val, dt) values ("2019-05-23", 12, "2019-05-22 02:00:00");
139
+ insert into tbl_a (d, val, dt) values ("2019-05-23", 12, "2019-05-22 02:00:00");
140
140
 
141
- insert into table_a (d, val, dt) values ("2019-05-23", 13, "2019-05-22 03:00:00");
141
+ insert into tbl_a (d, val, dt) values ("2019-05-23", 13, "2019-05-22 03:00:00");
142
142
 
143
- insert into table_a (d, val, dt) values ("2019-05-23", 14, "2019-05-22 04:00:00");
143
+ insert into tbl_a (d, val, dt) values ("2019-05-23", 14, "2019-05-22 04:00:00");
144
144
 
145
- insert into table_a (d, val, dt) values ("2019-05-23", 15, "2019-05-22 05:00:00");
145
+ insert into tbl_a (d, val, dt) values ("2019-05-23", 15, "2019-05-22 05:00:00");
146
146
 
147
- insert into table_a (d, val, dt) values ("2019-05-23", 16, "2019-05-22 06:00:00");
147
+ insert into tbl_a (d, val, dt) values ("2019-05-23", 16, "2019-05-22 06:00:00");
148
148
 
149
- insert into table_a (d, val, dt) values ("2019-05-23", 17, "2019-05-22 07:00:00");
149
+ insert into tbl_a (d, val, dt) values ("2019-05-23", 17, "2019-05-22 07:00:00");
150
150
 
151
151
 
152
152
 
153
- insert into table_b (d, val, dt) values ("2019-05-23", 20, "2019-05-22 02:00:00");
153
+ insert into tbl_b (d, val, dt) values ("2019-05-23", 20, "2019-05-22 02:00:00");
154
154
 
155
- insert into table_b (d, val, dt) values ("2019-05-23", 21, "2019-05-22 03:00:00");
155
+ insert into tbl_b (d, val, dt) values ("2019-05-23", 21, "2019-05-22 03:00:00");
156
156
 
157
- insert into table_b (d, val, dt) values ("2019-05-23", 22, "2019-05-22 04:00:00");
157
+ insert into tbl_b (d, val, dt) values ("2019-05-23", 22, "2019-05-22 04:00:00");
158
158
 
159
- insert into table_b (d, val, dt) values ("2019-05-23", 23, "2019-05-22 05:00:00");
159
+ insert into tbl_b (d, val, dt) values ("2019-05-23", 23, "2019-05-22 05:00:00");
160
160
 
161
- insert into table_b (d, val, dt) values ("2019-05-23", 24, "2019-05-22 06:00:00");
161
+ insert into tbl_b (d, val, dt) values ("2019-05-23", 24, "2019-05-22 06:00:00");
162
162
 
163
- insert into table_b (d, val, dt) values ("2019-05-23", 25, "2019-05-22 07:00:00");
163
+ insert into tbl_b (d, val, dt) values ("2019-05-23", 25, "2019-05-22 07:00:00");
164
164
 
165
- insert into table_b (d, val, dt) values ("2019-05-23", 26, "2019-05-22 08:00:00");
165
+ insert into tbl_b (d, val, dt) values ("2019-05-23", 26, "2019-05-22 08:00:00");
166
166
 
167
- insert into table_b (d, val, dt) values ("2019-05-23", 27, "2019-05-22 09:00:00");
167
+ insert into tbl_b (d, val, dt) values ("2019-05-23", 27, "2019-05-22 09:00:00");
168
168
 
169
- insert into table_b (d, val, dt) values ("2019-05-23", 28, "2019-05-22 10:00:00");
169
+ insert into tbl_b (d, val, dt) values ("2019-05-23", 28, "2019-05-22 10:00:00");
170
170
 
171
- insert into table_b (d, val, dt) values ("2019-05-23", 29, "2019-05-22 11:00:00");
171
+ insert into tbl_b (d, val, dt) values ("2019-05-23", 29, "2019-05-22 11:00:00");
172
172
 
173
173
 
174
174
 
175
- insert into table_c (d, val, dt) values ("2019-05-23", 30, "2019-05-22 03:00:00");
175
+ insert into tbl_a (d, val, dt) values ("2019-05-23", 30, "2019-05-22 03:00:00");
176
176
 
177
- insert into table_c (d, val, dt) values ("2019-05-23", 31, "2019-05-22 04:00:00");
177
+ insert into tbl_a (d, val, dt) values ("2019-05-23", 31, "2019-05-22 04:00:00");
178
178
 
179
- insert into table_c (d, val, dt) values ("2019-05-23", 32, "2019-05-22 05:00:00");
179
+ insert into tbl_a (d, val, dt) values ("2019-05-23", 32, "2019-05-22 05:00:00");
180
180
 
181
- insert into table_c (d, val, dt) values ("2019-05-23", 33, "2019-05-22 06:00:00");
181
+ insert into tbl_a (d, val, dt) values ("2019-05-23", 33, "2019-05-22 06:00:00");
182
182
 
183
183
  ```
184
184
 

2

試せるようにクエリを貼った

2021/01/15 02:40

投稿

aheshiyu_tt
aheshiyu_tt

スコア11

test CHANGED
File without changes
test CHANGED
@@ -113,3 +113,75 @@
113
113
 
114
114
 
115
115
  よろしくお願いします.
116
+
117
+
118
+
119
+ ### 補足
120
+
121
+
122
+
123
+ 以下に上記のデータを作成できるクエリを貼っておきます.
124
+
125
+ ```
126
+
127
+ create table table_a (d date, val int, dt datetime);
128
+
129
+ create table table_b (d date, val int, dt datetime);
130
+
131
+ create table table_c (d date, val int, dt datetime);
132
+
133
+
134
+
135
+ insert into table_a (d, val, dt) values ("2019-05-23", 10, "2019-05-22 00:00:00");
136
+
137
+ insert into table_a (d, val, dt) values ("2019-05-23", 11, "2019-05-22 01:00:00");
138
+
139
+ insert into table_a (d, val, dt) values ("2019-05-23", 12, "2019-05-22 02:00:00");
140
+
141
+ insert into table_a (d, val, dt) values ("2019-05-23", 13, "2019-05-22 03:00:00");
142
+
143
+ insert into table_a (d, val, dt) values ("2019-05-23", 14, "2019-05-22 04:00:00");
144
+
145
+ insert into table_a (d, val, dt) values ("2019-05-23", 15, "2019-05-22 05:00:00");
146
+
147
+ insert into table_a (d, val, dt) values ("2019-05-23", 16, "2019-05-22 06:00:00");
148
+
149
+ insert into table_a (d, val, dt) values ("2019-05-23", 17, "2019-05-22 07:00:00");
150
+
151
+
152
+
153
+ insert into table_b (d, val, dt) values ("2019-05-23", 20, "2019-05-22 02:00:00");
154
+
155
+ insert into table_b (d, val, dt) values ("2019-05-23", 21, "2019-05-22 03:00:00");
156
+
157
+ insert into table_b (d, val, dt) values ("2019-05-23", 22, "2019-05-22 04:00:00");
158
+
159
+ insert into table_b (d, val, dt) values ("2019-05-23", 23, "2019-05-22 05:00:00");
160
+
161
+ insert into table_b (d, val, dt) values ("2019-05-23", 24, "2019-05-22 06:00:00");
162
+
163
+ insert into table_b (d, val, dt) values ("2019-05-23", 25, "2019-05-22 07:00:00");
164
+
165
+ insert into table_b (d, val, dt) values ("2019-05-23", 26, "2019-05-22 08:00:00");
166
+
167
+ insert into table_b (d, val, dt) values ("2019-05-23", 27, "2019-05-22 09:00:00");
168
+
169
+ insert into table_b (d, val, dt) values ("2019-05-23", 28, "2019-05-22 10:00:00");
170
+
171
+ insert into table_b (d, val, dt) values ("2019-05-23", 29, "2019-05-22 11:00:00");
172
+
173
+
174
+
175
+ insert into table_c (d, val, dt) values ("2019-05-23", 30, "2019-05-22 03:00:00");
176
+
177
+ insert into table_c (d, val, dt) values ("2019-05-23", 31, "2019-05-22 04:00:00");
178
+
179
+ insert into table_c (d, val, dt) values ("2019-05-23", 32, "2019-05-22 05:00:00");
180
+
181
+ insert into table_c (d, val, dt) values ("2019-05-23", 33, "2019-05-22 06:00:00");
182
+
183
+ ```
184
+
185
+ paiza.io等でお試しください.
186
+
187
+ よろしくお願いします.

1

複雑な質問ではないにもかかわらず、あまりにも回答が来ないため、タイトルを変更してタグも追加しました

2021/01/15 02:35

投稿

aheshiyu_tt
aheshiyu_tt

スコア11

test CHANGED
@@ -1 +1 @@
1
- MySQL 複数のデータ結合
1
+ MySQL 複数のデータを、時刻を基準として漏れなく結合したい
test CHANGED
File without changes