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

oracle 视图多表关联查询,

时间:2015-08-19 19:34:40      阅读:255      评论:0      收藏:0      [点我收藏+]

标签:

select distinct
t.id,
p.palias,
cname,
c.currency_unit,
t.company_name isp, --运营商名称
t.code buessies, --下游客户名称
t.country_code, --国家码
t.price, --价格
t.country, --查出国家
‘1‘ gamecode,
to_char(t.receive_time,‘yyyymmdd‘) cdate,
to_char(t.receive_time,‘yyyymm‘) cmonth,
to_char(t.receive_time,‘yyyy‘) cyear,
to_char(t.receive_time,‘yyyy-mm-dd hh24:mi:ss‘) insertdate,
trunc(pt.one_income,3) priceRMB,--单条RMB收入 无附加坏帐率

s.bshark_local_income priceLocal, --黑鲨当地货币收入 已附加坏帐率
s.bshark_local_income * c.exchange_rate priceBshark, --黑鲨单条收入 当地货币*汇率
pt.partner_one_income pricePartner, --合作伙伴单条收入(RMB)
s.price totalPrice, --资费
trunc((c.exchange_rate*s.price),3) totalRMBPrice, --RMB资费
s.sp_name sp_name
from bs_dcb_message t,qgc_countrysp s ,qgc_country c,qgc_partner p,bs_price_table pt
where
lower(t.code)=lower(p.pname)
and lower(t.country_code)=lower(c.country_code)
and lower(s.isp)=lower(t.company_name)
and p.pname=t.code
and s.country_id = c.id --SP:通过SP的国家ID再次锁定SP
and pt.sp_id = s.id --通过SP找到对应的价格表
and pt.partner_id = p.id --合作伙伴:通过合作伙伴ID锁定合作伙伴的价格表

oracle 视图多表关联查询,

标签:

原文地址:http://www.cnblogs.com/jessi/p/4742902.html

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