假设一个表有两列名为“x”和“y”的列填充了数字;例如,x 包含值 (1, 2, 3),而 y 包含 (5, 8, 20)。
如何计算列的乘积之和,即 (1 × 5) + (2 × 8) + (3 × 20) = 81?
我需要在PSQL中的一个表中转换几列,我真的不想放弃表来解决这个问题(这是我的最后一招).有没有办法做到这一点,因为当我写:
ALTER TABLE table ALTER TABLE column type TIMESTAMP without time zone using column::TIMESTAMP without time zone;
Run Code Online (Sandbox Code Playgroud)
它不起作用,说:
ERROR:cannot cast type time without time zone to timestamp without time zone.
Run Code Online (Sandbox Code Playgroud)
PS如果可能,我想避免删除列,因为我已经使用了这些列的索引.