小编use*_*150的帖子

PostgreSQL:在同一查询中使用计算列

我在postgres中使用计算列时遇到问题.下面给出了一个在SQL中工作的类似代码,是否可以重新创建它PostgreSQL

select cost_1, quantity_1, cost_2, quantity_2, 
      (cost_1 * quantity_1) as total_1,
      (cost_2 * quantity_2) as total_2,
      (calculated total_1 + calculated total_2) as total_3
from data;
Run Code Online (Sandbox Code Playgroud)

PostgreSQL类似的代码中返回错误:

列total_1和total_2不存在.

sql postgresql calculated-columns

46
推荐指数
4
解决办法
4万
查看次数

标签 统计

calculated-columns ×1

postgresql ×1

sql ×1