回答編集履歴

2

調整

2019/06/20 04:22

投稿

yambejp
yambejp

スコア114883

test CHANGED
@@ -45,3 +45,85 @@
45
45
  ```
46
46
 
47
47
  に対して、2~3社、1週間分程度サンプルをあげてどこをどうひっかけたいか例示されるとよいでしょう
48
+
49
+
50
+
51
+ # 追記
52
+
53
+
54
+
55
+ 連続性についてはロジックがかなり煩雑になるので
56
+
57
+ 期間を入れることで対応してください
58
+
59
+ 以下サンプル
60
+
61
+ - 元データ
62
+
63
+ ```SQL
64
+
65
+ CREATE TABLE tbl(
66
+
67
+ SC int(4) NOT NULL,
68
+
69
+ today_close double,
70
+
71
+ today_open double,
72
+
73
+ `date` datetime NOT NULL
74
+
75
+ );
76
+
77
+
78
+
79
+ insert into tbl values
80
+
81
+ (1000,100,94,'2019-06-20 15:00'),
82
+
83
+ (2000,150,179,'2019-06-20 15:00'),
84
+
85
+ (3000,347,344,'2019-06-20 15:00'),
86
+
87
+ (1000,93,88,'2019-06-19 15:00'),
88
+
89
+ (2000,179,175,'2019-06-19 15:00'),
90
+
91
+ (3000,347,341,'2019-06-19 15:00'),
92
+
93
+ (1000,86,74,'2019-06-18 15:00'),
94
+
95
+ (2000,173,160,'2019-06-18 15:00'),
96
+
97
+ (3000,344,321,'2019-06-18 15:00'),
98
+
99
+ (1000,77,71,'2019-06-17 15:00'),
100
+
101
+ (2000,160,164,'2019-06-17 15:00'),
102
+
103
+ (3000,340,300,'2019-06-17 15:00');
104
+
105
+
106
+
107
+ ```
108
+
109
+
110
+
111
+ - 検索
112
+
113
+ ```SQL
114
+
115
+ select sc
116
+
117
+ ,group_concat(today_close order by date desc)=group_concat(today_close order by today_close desc) as is_down
118
+
119
+ ,max(date) as date
120
+
121
+ from tbl
122
+
123
+ where `date` between '2019-06-17 00:00:00' and '2019-06-20 23:59:59'
124
+
125
+ group by sc
126
+
127
+ ```
128
+
129
+ ※注意:datetimeのbetweenは00:00:00~23:59:59を指定すること

1

chousei

2019/06/20 04:21

投稿

yambejp
yambejp

スコア114883

test CHANGED
@@ -31,3 +31,17 @@
31
31
  ざっくりいらないデータを削って
32
32
 
33
33
  ```SQL
34
+
35
+ CREATE TABLE tbl(
36
+
37
+ SC int(4) NOT NULL,
38
+
39
+ `date` datetime NOT NULL,
40
+
41
+ today_close double,
42
+
43
+ today_open double);
44
+
45
+ ```
46
+
47
+ に対して、2~3社、1週間分程度サンプルをあげてどこをどうひっかけたいか例示されるとよいでしょう