【发布时间】:2019-03-19 17:02:52
【问题描述】:
考虑到 Postgres 9.5.1 中的以下时间序列数据,我正在尝试重塑为 array(int) |time_to_failure(double) 作为新表
# SELECT acoustic_data, time_to_failure FROM lanl_train WHERE
time_to_failure = '0.000795';
acoustic_data | time_to_failure
---------------+-----------------
2 | 0.000795
5 | 0.000795
6 | 0.000795
1 | 0.000795
2 | 0.000795
5 | 0.000795
8 | 0.000795
5 | 0.000795
4 | 0.000795
4 | 0.000795
7 | 0.000795
2 | 0.000795
2 | 0.000795
0 | 0.000795
0 | 0.000795
2 | 0.000795
4 | 0.000795
5 | 0.000795
4 | 0.000795
(19 rows)
# SELECT ARRAY(SELECT acoustic_data FROM lanl_train WHERE
time_to_failure = '0.000795');
array
-----------------------------------------
{2,5,6,1,2,5,8,5,4,4,7,2,2,0,0,2,4,5,4}
(1 row)
这样新表中的一行就会是
acoustic_data(array) | time_to_failure(double)
----------------------------------------------
{2,5,6,1,2,5,8,5,4,4,7,2,2,0,0,2,4,5,4} | 0.000795
我有一些零件,但我坚持使用 SELECT 来实现这个结果。非常感谢任何帮助。
【问题讨论】:
标签: sql postgresql