質問編集履歴

24

文言の変更

2018/09/18 07:55

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  ##現在の課題
2
2
 
3
- あるテーブルで、過去7ヶ月分のデータを取得したいのに、正常に7ヶ月分取得できません。
3
+ あるテーブルで、過去データを正常に取得できません。
4
4
 
5
5
  データはテーブルに入っているようなのですが、発行したクエリのWHERE条件と想定する結果が異なっており、
6
6
 
@@ -8,7 +8,7 @@
8
8
 
9
9
 
10
10
 
11
- ##実行したクエリ(修正しました)
11
+ ##実行したクエリ
12
12
 
13
13
  ```SQL
14
14
 
@@ -18,71 +18,13 @@
18
18
 
19
19
  , target_date
20
20
 
21
- , SUM(info)
22
-
23
- , SUM(tanto)
24
-
25
- , SUM(counts1)
26
-
27
- , SUM(info_float)
28
-
29
21
 
30
22
 
31
23
  FROM
32
24
 
33
25
  TEST_TABLE
34
26
 
35
-
36
-
37
- WHERE
38
-
39
- xxx_type = 1
40
-
41
- AND target_date BETWEEN "2018-02-01" AND "2018-09-01" - INTERVAL 1 DAY
42
-
43
- AND del_flg IS NULL
44
-
45
- AND condition_id = 1
46
-
47
-
48
-
49
- GROUP BY
50
-
51
- target_date
52
-
53
27
  ```
54
-
55
-
56
-
57
- **実際の結果**
58
-
59
- |xxx_type|condition_id|target_date|SUM(info)|SUM(tanto)|SUM(counts1)|SUM(info_float)|
60
-
61
- |:--|:--:|--:|
62
-
63
- 1|1|2018-02-01|10|20|30|40
64
-
65
-
66
-
67
- **理想の結果**
68
-
69
- |xxx_type|condition_id|target_date|SUM(info)|SUM(tanto)|SUM(counts1)|SUM(info_float)|
70
-
71
- |:--|:--:|--:|
72
-
73
- 1|1|2018-02-01|10|20|30|40
74
-
75
- 1|1|2018-03-01|10|20|30|40
76
-
77
- 1|1|2018-04-01|10|20|30|40
78
-
79
- 1|1|2018-05-01|10|20|30|40
80
-
81
- 1|1|2018-06-01|10|20|30|40
82
-
83
- 1|1|2018-07-01|10|20|30|40
84
-
85
- 1|1|2018-08-01|10|20|30|40
86
28
 
87
29
 
88
30
 
@@ -100,10 +42,6 @@
100
42
 
101
43
  ※テーブル名やクエリ名は仮のものです。
102
44
 
103
- ※データ型などもクエリに関係する部分以外は一部変更しています。
104
-
105
- ※NULL制約やキー設定等は変更していません。
106
-
107
45
 
108
46
 
109
47
  |Field|Type|Null|Key|Default|Extra|
@@ -112,193 +50,9 @@
112
50
 
113
51
  pri_id|int(11)|NO|PRI|NULL|auto_increment
114
52
 
115
- condition_id|int(11)|YES|MUL|NULL|
116
-
117
53
  target_date|date|NO|PRI|0000-00-00|
118
54
 
119
55
  xxx_type|int(11)|YES|MUL|NULL|
120
-
121
- user_type|int(11)|YES|MUL|NULL|
122
-
123
- counts1|int(11)|YES|MUL|NULL|
124
-
125
- info|int(11)|YES||NULL|
126
-
127
- tanto|int(11)|YES||NULL|
128
-
129
- counts3|int(11)|YES|MUL|NULL|
130
-
131
- client|int(11)|YES|MUL|NULL|
132
-
133
- ex_no|int(11)|YES|MUL|NULL|
134
-
135
- counts4|int(11)|YES|MUL|NULL|
136
-
137
- data_float|float|YES|MUL|NULL|
138
-
139
- info_float|float|YES|MUL|NULL|
140
-
141
- bikou|varchar(255)|YES|MUL|NULL|
142
-
143
- touroku_dt|datetime|YES||NULL|
144
-
145
- del_flg|int(11)|YES||NULL|
146
-
147
- del_date|date|YES||NULL|
148
-
149
-
150
-
151
- ##検証して判明したこと
152
-
153
- ・WHERE条件の"target_date"を"date(target_date)"のようにすると、
154
-
155
- 理想の結果が出る
156
-
157
- → 何故型を明示的に変換すると結果変わる?
158
-
159
-
160
-
161
- ・"condition_id"が"1"の場合のみ1件しか表示されない("2"や"3")の場合は問題ない
162
-
163
-  → condition_id = "1"のデータは入っている
164
-
165
-
166
-
167
- ・CHECK TABLEでテーブル定義が破損していないかを確認しましたが、
168
-
169
-  エラーは特に検出されませんでした。
170
-
171
-
172
-
173
- ・必ず日付範囲指定の下限の方のデータが表示されます。
174
-
175
- 下が2018-02-01なら2018-02-01のデータのみ、2018-07-01なら2018-07-1のデータのみが表示されるようです。
176
-
177
-
178
-
179
- ・MySQLバージョンは5.5.40です。
180
-
181
-
182
-
183
- ・2ヶ月ほど前に、ローカル環境にエクスポートしたDB定義で環境をコピーしたものがあるので、
184
-
185
- そちらで同じSQLを実行してみたところ、正常に結果が取得できました。
186
-
187
-
188
-
189
- ##検証したクエリの実行計画
190
-
191
- ・explainでもともとのクエリに対し実行計画を確認してみた結果です。(一部しか出力されない)
192
-
193
- |id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
194
-
195
- |:--|:--:|--:|
196
-
197
- 1|SIMPLE|TEST_TABLE|index_merge|idx_target_date,idx_condition_id,idx_xxx_type,idx_mix_condition_id|idx_xxx_type,idx_condition_id|5,5|NULL|1|Using intersect(idx_xxx_type,idx_condition_id); Using where; Using temporary; Using filesort
198
-
199
-
200
-
201
- ・"target_date"を"date(target_date)"にした時の実行計画です(出力される)
202
-
203
- |id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
204
-
205
- |:--|:--:|--:|
206
-
207
- 1|SIMPLE|TEST_TABLE|ref|idx_condition_id,idx_xxx_type,idx_mix_condition_id|idx_xxx_type|5|const|371|Using where; Using temporary; Using filesort
208
-
209
-
210
-
211
- ・"condition_id"を1以外の値に指定した場合の実行計画です(出力される)
212
-
213
- |id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
214
-
215
- |:--|:--:|--:|
216
-
217
- 1|SIMPLE|TEST_TABLE|ref|idx_target_date,idx_condition_id,idx_xxx_type,idx_mix_condition_id|idx_xxx_type|5|const|170|Using where; Using temporary; Using filesort
218
-
219
-
220
-
221
- ・ローカル環境で同じクエリを実行したとき(出力される)
222
-
223
- |id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
224
-
225
- |:--|:--:|--:|
226
-
227
- 1|SIMPLE|TEST_TABLE|index_merge|idx_target_date,idx_condition_id,idx_xxx_type,idx_mix_condition_id|idx_xxx_type,idx_condition_id|5,5|<NULL>|1|Using intersect(idx_xxx_type,idx_condition_id); Using where; Using temporary; Using filesort
228
-
229
-
230
-
231
- ##追記 不可解な動作
232
-
233
- 検証用に以下のクエリを発行してみました。
234
-
235
- ```SQL
236
-
237
-
238
-
239
- SELECT
240
-
241
- pri_id, condition_id, target_date
242
-
243
-
244
-
245
- FROM
246
-
247
- TEST_TABLE
248
-
249
-
250
-
251
- WHERE
252
-
253
- xxx_type = 1
254
-
255
- AND condition_id = 1
256
-
257
- AND del_flg IS NULL
258
-
259
-
260
-
261
- ORDER BY
262
-
263
- target_date
264
-
265
- ```
266
-
267
- この結果が以下のように、
268
-
269
- 1, 1, 2017-12-01
270
-
271
- 2, 1, 2018-01-01
272
-
273
- 3, 1, 2018-02-01
274
-
275
- 4, 1, 2018-03-01
276
-
277
- 5, 1, 2018-04-01
278
-
279
- 6, 1, 2018-05-01 ・・・ のように続くにもかかわらず
280
-
281
-
282
-
283
- WHERE条件に「AND target_date BETWEEN '2018-03-01' AND '2018-09-01' - INTERVAL 1 DAY 」を追加すると、
284
-
285
- 結果が以下のように、
286
-
287
- 4, 1, 2018-03-01
288
-
289
- の1件のみとなってしまう。
290
-
291
-
292
-
293
-
294
-
295
-
296
-
297
-  
298
-
299
-  
300
-
301
-  
302
56
 
303
57
 
304
58
 

23

検証結果の修正(一部誤りがあった)

2018/09/18 07:55

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -268,15 +268,15 @@
268
268
 
269
269
  1, 1, 2017-12-01
270
270
 
271
- 1, 1, 2018-01-01
271
+ 2, 1, 2018-01-01
272
-
272
+
273
- 1, 1, 2018-02-01
273
+ 3, 1, 2018-02-01
274
-
274
+
275
- 1, 1, 2018-03-01
275
+ 4, 1, 2018-03-01
276
-
276
+
277
- 1, 1, 2018-04-01
277
+ 5, 1, 2018-04-01
278
-
278
+
279
- 1, 1, 2018-05-01 ・・・ のように続くにもかかわらず
279
+ 6, 1, 2018-05-01 ・・・ のように続くにもかかわらず
280
280
 
281
281
 
282
282
 
@@ -284,7 +284,7 @@
284
284
 
285
285
  結果が以下のように、
286
286
 
287
- 1, 1, 2018-03-01
287
+ 4, 1, 2018-03-01
288
288
 
289
289
  の1件のみとなってしまう。
290
290
 

22

文言の追記

2018/09/04 02:05

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -230,6 +230,8 @@
230
230
 
231
231
  ##追記 不可解な動作
232
232
 
233
+ 検証用に以下のクエリを発行してみました。
234
+
233
235
  ```SQL
234
236
 
235
237
 

21

検証結果の追記

2018/09/04 01:56

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -180,6 +180,14 @@
180
180
 
181
181
 
182
182
 
183
+ ・2ヶ月ほど前に、ローカル環境にエクスポートしたDB定義で環境をコピーしたものがあるので、
184
+
185
+ そちらで同じSQLを実行してみたところ、正常に結果が取得できました。
186
+
187
+
188
+
189
+ ##検証したクエリの実行計画
190
+
183
191
  ・explainでもともとのクエリに対し実行計画を確認してみた結果です。(一部しか出力されない)
184
192
 
185
193
  |id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
@@ -220,6 +228,68 @@
220
228
 
221
229
 
222
230
 
231
+ ##追記 不可解な動作
232
+
233
+ ```SQL
234
+
235
+
236
+
237
+ SELECT
238
+
239
+ pri_id, condition_id, target_date
240
+
241
+
242
+
243
+ FROM
244
+
245
+ TEST_TABLE
246
+
247
+
248
+
249
+ WHERE
250
+
251
+ xxx_type = 1
252
+
253
+ AND condition_id = 1
254
+
255
+ AND del_flg IS NULL
256
+
257
+
258
+
259
+ ORDER BY
260
+
261
+ target_date
262
+
263
+ ```
264
+
265
+ この結果が以下のように、
266
+
267
+ 1, 1, 2017-12-01
268
+
269
+ 1, 1, 2018-01-01
270
+
271
+ 1, 1, 2018-02-01
272
+
273
+ 1, 1, 2018-03-01
274
+
275
+ 1, 1, 2018-04-01
276
+
277
+ 1, 1, 2018-05-01 ・・・ のように続くにもかかわらず
278
+
279
+
280
+
281
+ WHERE条件に「AND target_date BETWEEN '2018-03-01' AND '2018-09-01' - INTERVAL 1 DAY 」を追加すると、
282
+
283
+ 結果が以下のように、
284
+
285
+ 1, 1, 2018-03-01
286
+
287
+ の1件のみとなってしまう。
288
+
289
+
290
+
291
+
292
+
223
293
 
224
294
 
225
295
   
@@ -228,10 +298,6 @@
228
298
 
229
299
   
230
300
 
231
- ・2ヶ月ほど前に、ローカル環境にエクスポートしたDB定義で環境をコピーしたものがあるので、
232
-
233
- そちらで同じSQLを実行してみたところ、正常に結果が取得できました。
234
-
235
301
 
236
302
 
237
303
 

20

実行計画の追記

2018/09/04 01:54

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -210,6 +210,16 @@
210
210
 
211
211
 
212
212
 
213
+ ・ローカル環境で同じクエリを実行したとき(出力される)
214
+
215
+ |id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
216
+
217
+ |:--|:--:|--:|
218
+
219
+ 1|SIMPLE|TEST_TABLE|index_merge|idx_target_date,idx_condition_id,idx_xxx_type,idx_mix_condition_id|idx_xxx_type,idx_condition_id|5,5|<NULL>|1|Using intersect(idx_xxx_type,idx_condition_id); Using where; Using temporary; Using filesort
220
+
221
+
222
+
213
223
 
214
224
 
215
225
   

19

文言の変更

2018/09/04 01:36

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -180,7 +180,7 @@
180
180
 
181
181
 
182
182
 
183
- ・explainでもともとのクエリに対し実行計画を確認してみた結果です。
183
+ ・explainでもともとのクエリに対し実行計画を確認してみた結果です。(一部しか出力されない)
184
184
 
185
185
  |id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
186
186
 
@@ -190,7 +190,7 @@
190
190
 
191
191
 
192
192
 
193
- ・"target_date"を"date(target_date)"にした時の実行計画です
193
+ ・"target_date"を"date(target_date)"にした時の実行計画です(出力される)
194
194
 
195
195
  |id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
196
196
 
@@ -200,7 +200,7 @@
200
200
 
201
201
 
202
202
 
203
- ・"condition_id"を1以外の値に指定した場合の実行計画です
203
+ ・"condition_id"を1以外の値に指定した場合の実行計画です(出力される)
204
204
 
205
205
  |id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
206
206
 

18

検証の追記

2018/09/04 01:19

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -200,6 +200,16 @@
200
200
 
201
201
 
202
202
 
203
+ ・"condition_id"を1以外の値に指定した場合の実行計画です
204
+
205
+ |id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
206
+
207
+ |:--|:--:|--:|
208
+
209
+ 1|SIMPLE|TEST_TABLE|ref|idx_target_date,idx_condition_id,idx_xxx_type,idx_mix_condition_id|idx_xxx_type|5|const|170|Using where; Using temporary; Using filesort
210
+
211
+
212
+
203
213
 
204
214
 
205
215
   

17

検証の追記

2018/09/04 01:18

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -180,7 +180,7 @@
180
180
 
181
181
 
182
182
 
183
- ・explainで実行計画を確認してみた結果です。
183
+ ・explainでもともとのクエリに対し実行計画を確認してみた結果です。
184
184
 
185
185
  |id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
186
186
 
@@ -188,16 +188,26 @@
188
188
 
189
189
  1|SIMPLE|TEST_TABLE|index_merge|idx_target_date,idx_condition_id,idx_xxx_type,idx_mix_condition_id|idx_xxx_type,idx_condition_id|5,5|NULL|1|Using intersect(idx_xxx_type,idx_condition_id); Using where; Using temporary; Using filesort
190
190
 
191
+
192
+
193
+ ・"target_date"を"date(target_date)"にした時の実行計画です
194
+
195
+ |id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
196
+
197
+ |:--|:--:|--:|
198
+
199
+ 1|SIMPLE|TEST_TABLE|ref|idx_condition_id,idx_xxx_type,idx_mix_condition_id|idx_xxx_type|5|const|371|Using where; Using temporary; Using filesort
200
+
201
+
202
+
203
+
204
+
191
205
   
192
206
 
193
-
194
-
195
207
   
196
208
 
197
209
   
198
210
 
199
-  
200
-
201
211
  ・2ヶ月ほど前に、ローカル環境にエクスポートしたDB定義で環境をコピーしたものがあるので、
202
212
 
203
213
  そちらで同じSQLを実行してみたところ、正常に結果が取得できました。

16

レイアウトの変更

2018/09/04 01:14

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -190,6 +190,12 @@
190
190
 
191
191
   
192
192
 
193
+
194
+
195
+  
196
+
197
+  
198
+
193
199
   
194
200
 
195
201
  ・2ヶ月ほど前に、ローカル環境にエクスポートしたDB定義で環境をコピーしたものがあるので、
@@ -200,8 +206,6 @@
200
206
 
201
207
 
202
208
 
203
-
204
-
205
209
  あまり多くない情報の中大変恐縮ではありますが、
206
210
 
207
211
  何か原因に心当たりのある方がいれば、ご教示いただきたく存じます。

15

文言の変更

2018/09/04 01:06

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -188,7 +188,9 @@
188
188
 
189
189
  1|SIMPLE|TEST_TABLE|index_merge|idx_target_date,idx_condition_id,idx_xxx_type,idx_mix_condition_id|idx_xxx_type,idx_condition_id|5,5|NULL|1|Using intersect(idx_xxx_type,idx_condition_id); Using where; Using temporary; Using filesort
190
190
 
191
-
191
+  
192
+
193
+  
192
194
 
193
195
  ・2ヶ月ほど前に、ローカル環境にエクスポートしたDB定義で環境をコピーしたものがあるので、
194
196
 

14

検証の追記

2018/09/04 01:04

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -190,6 +190,12 @@
190
190
 
191
191
 
192
192
 
193
+ ・2ヶ月ほど前に、ローカル環境にエクスポートしたDB定義で環境をコピーしたものがあるので、
194
+
195
+ そちらで同じSQLを実行してみたところ、正常に結果が取得できました。
196
+
197
+
198
+
193
199
 
194
200
 
195
201
 

13

monngonnnohennkou

2018/09/04 01:04

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -186,7 +186,7 @@
186
186
 
187
187
  |:--|:--:|--:|
188
188
 
189
- 1|SIMPLE|tb_access_data_month|index_merge|idx_target_date,idx_condition_id,idx_xxx_type,idx_mix_condition_id|idx_xxx_type,idx_condition_id|5,5|NULL|1|Using intersect(idx_xxx_type,idx_condition_id); Using where; Using temporary; Using filesort
189
+ 1|SIMPLE|TEST_TABLE|index_merge|idx_target_date,idx_condition_id,idx_xxx_type,idx_mix_condition_id|idx_xxx_type,idx_condition_id|5,5|NULL|1|Using intersect(idx_xxx_type,idx_condition_id); Using where; Using temporary; Using filesort
190
190
 
191
191
 
192
192
 

12

文言の変更

2018/09/04 00:39

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -186,7 +186,7 @@
186
186
 
187
187
  |:--|:--:|--:|
188
188
 
189
- 1|SIMPLE|tb_access_data_month|index_merge|idx_d_target,idx_ga_condition_id,idx_i_analysis_type,idx_mix_ga_condition_id|idx_i_analysis_type,idx_ga_condition_id|5,5|NULL|1|Using intersect(idx_i_analysis_type,idx_ga_condition_id); Using where; Using temporary; Using filesort
189
+ 1|SIMPLE|tb_access_data_month|index_merge|idx_target_date,idx_condition_id,idx_xxx_type,idx_mix_condition_id|idx_xxx_type,idx_condition_id|5,5|NULL|1|Using intersect(idx_xxx_type,idx_condition_id); Using where; Using temporary; Using filesort
190
190
 
191
191
 
192
192
 

11

初心者アイコンを一度削除いたしました。

2018/09/04 00:38

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
File without changes

10

実行計画の追記 実行クエリの変更

2018/09/03 23:52

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -8,15 +8,13 @@
8
8
 
9
9
 
10
10
 
11
- ##実行したクエリ
11
+ ##実行したクエリ(修正しました)
12
12
 
13
13
  ```SQL
14
14
 
15
15
  SELECT
16
16
 
17
- xxx_type
17
+ MIN(xxx_type)
18
-
19
- , condition_id
20
18
 
21
19
  , target_date
22
20
 
@@ -40,9 +38,7 @@
40
38
 
41
39
  xxx_type = 1
42
40
 
43
- AND target_date >= "2018-02-01"
44
-
45
- AND target_date < "2018-09-01"
41
+ AND target_date BETWEEN "2018-02-01" AND "2018-09-01" - INTERVAL 1 DAY
46
42
 
47
43
  AND del_flg IS NULL
48
44
 
@@ -184,6 +180,18 @@
184
180
 
185
181
 
186
182
 
183
+ ・explainで実行計画を確認してみた結果です。
184
+
185
+ |id|select_type|table|type|possible_keys|key|key_len|ref|rows|Extra|
186
+
187
+ |:--|:--:|--:|
188
+
189
+ 1|SIMPLE|tb_access_data_month|index_merge|idx_d_target,idx_ga_condition_id,idx_i_analysis_type,idx_mix_ga_condition_id|idx_i_analysis_type,idx_ga_condition_id|5,5|NULL|1|Using intersect(idx_i_analysis_type,idx_ga_condition_id); Using where; Using temporary; Using filesort
190
+
191
+
192
+
193
+
194
+
187
195
 
188
196
 
189
197
  あまり多くない情報の中大変恐縮ではありますが、

9

検証の追記

2018/09/03 23:50

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -180,6 +180,8 @@
180
180
 
181
181
 
182
182
 
183
+ ・MySQLバージョンは5.5.40です。
184
+
183
185
 
184
186
 
185
187
 

8

検証の追記

2018/09/03 09:59

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -174,6 +174,14 @@
174
174
 
175
175
 
176
176
 
177
+ ・必ず日付範囲指定の下限の方のデータが表示されます。
178
+
179
+ 下が2018-02-01なら2018-02-01のデータのみ、2018-07-01なら2018-07-1のデータのみが表示されるようです。
180
+
181
+
182
+
183
+
184
+
177
185
 
178
186
 
179
187
  あまり多くない情報の中大変恐縮ではありますが、

7

検証の追記

2018/09/03 09:47

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -168,6 +168,12 @@
168
168
 
169
169
 
170
170
 
171
+ ・CHECK TABLEでテーブル定義が破損していないかを確認しましたが、
172
+
173
+  エラーは特に検出されませんでした。
174
+
175
+
176
+
171
177
 
172
178
 
173
179
  あまり多くない情報の中大変恐縮ではありますが、

6

文言の変更

2018/09/03 09:42

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -132,7 +132,7 @@
132
132
 
133
133
  counts3|int(11)|YES|MUL|NULL|
134
134
 
135
- entrances|int(11)|YES|MUL|NULL|
135
+ client|int(11)|YES|MUL|NULL|
136
136
 
137
137
  ex_no|int(11)|YES|MUL|NULL|
138
138
 

5

文言の変更

2018/09/03 09:40

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -138,7 +138,7 @@
138
138
 
139
139
  counts4|int(11)|YES|MUL|NULL|
140
140
 
141
- time_on_xxx|float|YES|MUL|NULL|
141
+ data_float|float|YES|MUL|NULL|
142
142
 
143
143
  info_float|float|YES|MUL|NULL|
144
144
 

4

文言の変更

2018/09/03 09:10

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -20,13 +20,13 @@
20
20
 
21
21
  , target_date
22
22
 
23
- , SUM(sessions)
23
+ , SUM(info)
24
24
 
25
25
  , SUM(tanto)
26
26
 
27
27
  , SUM(counts1)
28
28
 
29
- , SUM(session_float)
29
+ , SUM(info_float)
30
30
 
31
31
 
32
32
 
@@ -60,7 +60,7 @@
60
60
 
61
61
  **実際の結果**
62
62
 
63
- |xxx_type|condition_id|target_date|SUM(sessions)|SUM(tanto)|SUM(counts1)|SUM(session_float)|
63
+ |xxx_type|condition_id|target_date|SUM(info)|SUM(tanto)|SUM(counts1)|SUM(info_float)|
64
64
 
65
65
  |:--|:--:|--:|
66
66
 
@@ -70,7 +70,7 @@
70
70
 
71
71
  **理想の結果**
72
72
 
73
- |xxx_type|condition_id|target_date|SUM(sessions)|SUM(tanto)|SUM(counts1)|SUM(session_float)|
73
+ |xxx_type|condition_id|target_date|SUM(info)|SUM(tanto)|SUM(counts1)|SUM(info_float)|
74
74
 
75
75
  |:--|:--:|--:|
76
76
 
@@ -126,7 +126,7 @@
126
126
 
127
127
  counts1|int(11)|YES|MUL|NULL|
128
128
 
129
- sessions|int(11)|YES||NULL|
129
+ info|int(11)|YES||NULL|
130
130
 
131
131
  tanto|int(11)|YES||NULL|
132
132
 
@@ -140,7 +140,7 @@
140
140
 
141
141
  time_on_xxx|float|YES|MUL|NULL|
142
142
 
143
- session_float|float|YES|MUL|NULL|
143
+ info_float|float|YES|MUL|NULL|
144
144
 
145
145
  bikou|varchar(255)|YES|MUL|NULL|
146
146
 

3

追記

2018/09/03 09:09

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -158,9 +158,13 @@
158
158
 
159
159
  理想の結果が出る
160
160
 
161
+ → 何故型を明示的に変換すると結果変わる?
162
+
161
163
 
162
164
 
163
165
  ・"condition_id"が"1"の場合のみ1件しか表示されない("2"や"3")の場合は問題ない
166
+
167
+  → condition_id = "1"のデータは入っている
164
168
 
165
169
 
166
170
 

2

文言の変更

2018/09/03 09:06

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -22,7 +22,7 @@
22
22
 
23
23
  , SUM(sessions)
24
24
 
25
- , SUM(users)
25
+ , SUM(tanto)
26
26
 
27
27
  , SUM(counts1)
28
28
 
@@ -60,7 +60,7 @@
60
60
 
61
61
  **実際の結果**
62
62
 
63
- |xxx_type|condition_id|target_date|SUM(sessions)|SUM(users)|SUM(counts1)|SUM(session_float)|
63
+ |xxx_type|condition_id|target_date|SUM(sessions)|SUM(tanto)|SUM(counts1)|SUM(session_float)|
64
64
 
65
65
  |:--|:--:|--:|
66
66
 
@@ -70,7 +70,7 @@
70
70
 
71
71
  **理想の結果**
72
72
 
73
- |xxx_type|condition_id|target_date|SUM(sessions)|SUM(users)|SUM(counts1)|SUM(session_float)|
73
+ |xxx_type|condition_id|target_date|SUM(sessions)|SUM(tanto)|SUM(counts1)|SUM(session_float)|
74
74
 
75
75
  |:--|:--:|--:|
76
76
 
@@ -128,13 +128,13 @@
128
128
 
129
129
  sessions|int(11)|YES||NULL|
130
130
 
131
- users|int(11)|YES||NULL|
131
+ tanto|int(11)|YES||NULL|
132
132
 
133
133
  counts3|int(11)|YES|MUL|NULL|
134
134
 
135
135
  entrances|int(11)|YES|MUL|NULL|
136
136
 
137
- exits|int(11)|YES|MUL|NULL|
137
+ ex_no|int(11)|YES|MUL|NULL|
138
138
 
139
139
  counts4|int(11)|YES|MUL|NULL|
140
140
 

1

文言の変更

2018/09/03 09:04

投稿

shakevo
shakevo

スコア453

test CHANGED
File without changes
test CHANGED
@@ -1,4 +1,4 @@
1
- ##困っていること
1
+ ##現在の課題
2
2
 
3
3
  あるテーブルで、過去7ヶ月分のデータを取得したいのに、正常に7ヶ月分取得できません。
4
4