sql六表联查

完成后是这样的

在这里插入图片描述

sql六表联查


select
case when (select  u.ui_name from user_info u where u.ui_delflag='0' and  rownum<2 and  u.ui_username=(select pr.pr_uid from  PORT_RESEARCH pr where pr.pr_dleflag='0' and  t.pri_foreign_key = pr.pr_fid)) is null then 
t.pri_portname else  (select  u.ui_name from user_info u where u.ui_delflag='0' and  rownum<2 and  u.ui_username=(select pr.pr_uid from  PORT_RESEARCH pr where pr.pr_dleflag='0' and  t.pri_foreign_key = pr.pr_fid))
 end,
--(select  u.ui_name from user_info u where u.ui_delflag='0' and  rownum<2 and  u.ui_username=(select pr.pr_uid from  PORT_RESEARCH pr where pr.pr_dleflag='0' and  t.pri_foreign_key = pr.pr_fid)),
--(select  u.ui_city from user_info u where u.ui_delflag='0' and  rownum<2 and u.ui_username=(select pr.pr_uid from  PORT_RESEARCH pr where  pr.pr_dleflag='0'and  t.pri_foreign_key = pr.pr_fid)),
case when (select  u.ui_city from user_info u where u.ui_delflag='0' and  rownum<2 and u.ui_username=(select pr.pr_uid from  PORT_RESEARCH pr where  pr.pr_dleflag='0'and  t.pri_foreign_key = pr.pr_fid)) is null then 
  (select ui.ui_city from user_info ui where ui.ui_name = t.pri_portname and ui.ui_delflag='0' and rownum<2)
  else (select  u.ui_city from user_info u where u.ui_delflag='0' and  rownum<2 and u.ui_username=(select pr.pr_uid from  PORT_RESEARCH pr where  pr.pr_dleflag='0'and  t.pri_foreign_key = pr.pr_fid))
  end ,
t.pri_portname,
(select b.b_name from BERTH b where b.b_delflag='0' and  t.pri_berthname=b.b_fid  and  b.b_wharf_id=(select pr.pr_uid from  PORT_RESEARCH pr where t.pri_foreign_key = pr.pr_fid)),
(select sd.sdd_dictionary_cname from sys_data_dictionary sd where sd.sdd_delfalg='0' and sd.sdd_dictionary_code=t.pri_commodity and sd.sdd_dictionary='0100'),
t.pri_machinery_category,t.pri_machinery_name,t.pri_power,t.pri_tonnage,t.pri_quantity,
(select sd.sdd_dictionary_cname from sys_data_dictionary sd where sd.sdd_delfalg='0' and sd.sdd_dictionary_code=t.pri_commodity and sd.sdd_dictionary='0200'),
(select sd.sdd_dictionary_cname from sys_data_dictionary sd where sd.sdd_delfalg='0' and sd.sdd_dictionary_code=t.pri_commodity and sd.sdd_dictionary='0300'),
(select sd.sdd_dictionary_cname from sys_data_dictionary sd where sd.sdd_delfalg='0' and sd.sdd_dictionary_code=t.pri_commodity and sd.sdd_dictionary='0400'),
(select sd.sdd_dictionary_cname from sys_data_dictionary sd where sd.sdd_delfalg='0' and sd.sdd_dictionary_code=t.pri_commodity and sd.sdd_dictionary='0500'),
t.pri_transform_time,t.pri_transform_quantity,t.pri_energy_after,
(case when (select te.name from temp te where te.name =t.pri_portname) is null then 1 else 0 end ),
(select ui_name from user_info where ui_delflag='0' and rownum < 2 and   ui_username = (select pr.pr_uid from  PORT_RESEARCH pr where t.pri_foreign_key = pr.pr_fid)),
(select ui_city from user_info where ui_delflag='0' and rownum < 2 and   ui_username = (select pr.pr_uid from  PORT_RESEARCH pr where t.pri_foreign_key = pr.pr_fid))
from PORT_RESEARCH_INFO t
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值