码迷,mamicode.com
首页 > 数据库 > 详细

Oracle查询结果列的加减、求和、连接、列值相乘

时间:2015-05-27 20:39:13      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:

select prod.amount,prod.plansum,(prod.plansum-prod.amount) as borrow,d.enum_value from ----结果集相减
(select t.Quo_Prod_List_Price * t.QUO_PROD_VOLUME as amount ,----列值相乘
       t.quo_prod_plan_cost * t.quo_prod_volume as plansum , t.broad_class as broad_class
       from CP_QUOTATION_PROD t where t.quotation_id = ‘8‘) prod
left join
CP_ENUM_DICT d
on
prod.broad_class = d.enum_id
union ----连接查询汇总的数据  行1+行2  注意列名需对应 列类型对应  不够的列添加冗余 
select sum(t.Quo_Prod_List_Price * t.QUO_PROD_VOLUME ) as amount ,
       sum(t.quo_prod_plan_cost * t.quo_prod_volume) as plansum,0 as borrow ,‘0‘ as enum_value
from CP_QUOTATION_PROD t where t.quotation_id = ‘8‘

技术分享

 技术分享

Oracle查询结果列的加减、求和、连接、列值相乘

标签:

原文地址:http://www.cnblogs.com/yeyuchangfeng/p/4534177.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!