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_3from data;
在Postgresql中,类似的代码返回错误:
您需要将SELECT语句包装到派生表中才能访问列别名:the column total_1 and total_2 do not exist.
select cost1,quantity_2 total_1 + total_2 as total_3from ( select cost_1,(cost_2 * quantity_2) as total_2 from data) t
不会有任何性能损失.
(我真的很惊讶你的原始SQL语句在DBMS中运行)
总结以上是内存溢出为你收集整理的PostgreSQL:在同一查询中使用计算列全部内容,希望文章能够帮你解决PostgreSQL:在同一查询中使用计算列所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)