我在 PostgreSQL 中有一个带有时间戳和值的表。
我想在“lat”下插入缺失的值。
“lat”下的值是基准面以上的潮汐高度。为此,可以在两个已知值之间线性插入缺失值。
在 PostgreSQL 中执行此操作的最佳方法是什么?
编辑20200825
我使用 QGIS 字段计算器以不同的方式解决了这个问题。这种方法的问题是:它需要很长时间,并且该进程在客户端运行,我想直接在服务器上运行它。
分步骤来说,我的工作流程是:
在QGIS中:
tidal_step =
-- the lat value @ the epoch, 10 minutes or 600000 miliseconds from the current epoch:
(attribute(get_feature('werkset','epoch',("epoch"+'600000')),'lat') -
-- the lat value @ the current
attribute(get_feature('werkset','epoch',"epoch"),'lat'))
/10
Run Code Online (Sandbox Code Playgroud)
对于示例图像中的前两个值,结果为: (4.95 - 5.07) /10 = -0.012
在QGIS中:
left(
right("timestamp",8) --this takes the timestamp and goes 8 charakters from the right
,1) -- this takes the string from the previous right( and goes …
Run Code Online (Sandbox Code Playgroud) postgresql ×1