我有这个BigQuery表中的数据
+-------+---------+------+------+
| chrom | start | stop | cons |
+-------+---------+------+------+
| chr1 | 1 | 5 | 0.3 |
| chr1 | 5 | 7 | 0.7 |
| chr2 | 1 | 3 | 0.2 |
+-------+---------+------+------+
其中" cons"中的值对于从开始到停止的每个数字都是如此(尽管不包括停止中的数字)。现在我想以非聚合的方式获取数据,因此表格看起来像这样
+-------+---------+------+------+
| chrom | start | stop | cons |
+-------+---------+------+------+
| chr1 | 1 | 2 | 0.3 |
| chr1 | 2 | 3 | 0.3 |
| chr1 | 3 | 4 | 0.3 |
| chr1 | 4 | 5 | 0.3 |
| chr1 | 5 | 6 | 0.7 |
| chr1 | 6 | 7 | 0.7 |
| chr2 | 1 | 2 | 0.2 |
| chr2 | 2 | 3 | 0.2 |
+-------+---------+------+------+
INSERT INTO
BigQuery不支持命令。有关解决方法的任何建议吗?
答案 0 :(得分:2)
它应该类似于:
Select chrome, Numbers.Number as Start, Numbers.Number+1 as stop, cons
from yourtable
cross join Numbers
where Numbers.Number>=Start and Number.Number<stop
希望这有帮助