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'
天涯雪