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

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'

 

posted @ 2015-05-27 18:51  长风傲天  阅读(16049)  评论(0编辑  收藏  举报
[h1[ [B]天涯雪[/B] [/h1]