Oracle sql问题,返回表联接上具有空值的行

Oracle sql问题,返回表联接上具有空值的行,sql,oracle,views,Sql,Oracle,Views,我正在处理一个视图(最初不是我自己创建的),我正在尝试返回没有分配小时数的请求(表别名req)(表别名te),我正在努力获得任何类型的外部联接,以便在以下sql上返回此请求: SELECT te.tc_date_yyyy_ww, te.tc_date_yyyy_mm, te.tc_date_yyyy, te.dc_date, te.nc_request_id_fk, te.nc_subrequest_id_fk, te.tc_clock, te.nc_hours, te.nc_am

我正在处理一个视图(最初不是我自己创建的),我正在尝试返回没有分配小时数的请求(表别名req)(表别名te),我正在努力获得任何类型的外部联接,以便在以下sql上返回此请求:

SELECT 
te.tc_date_yyyy_ww, 
te.tc_date_yyyy_mm, 
te.tc_date_yyyy, 
te.dc_date,
te.nc_request_id_fk, 
te.nc_subrequest_id_fk, 
te.tc_clock,
te.nc_hours, 
te.nc_amount, 
te.nc_discipline_id_fk,
te.tc_discipline_desc, 
req.tc_request_name, 
req.mc_project_cost,
req.nt_fetr_project, 
req.nc_bus_unit_id_fk, 
req.nc_location_id_fk,
req.nc_cemt_status_id_fk,
coord.tc_user_fname || ' ' || coord.tc_user_lname AS projectcoodname,
assoc.tc_fname || ' ' || assoc.tc_lname AS empname,
assoc_disc.tc_long_desc AS user_discipline,
sr.tc_name AS child_project, 
sr.tc_cost_center_or_wbs,
sr.tc_cost_center_nbr, 
sr.tc_cost_center_desc,
sr.tc_profit_center_desc, 
sr.tc_profit_center_nbr, 
sr.tc_wbs_nbr,
sr.tc_wbs_desc, 
sr.nc_child_type_id_fk, 
sre.nc_estimate,
stat_li.tc_med_desc AS req_status,
NVL(PP.NC_PRIORITY,0) AS PRIORITY
 FROM te07fear.tbye10_time_entry te,
      te07fear.tbxg100_requests req,
      (SELECT *
         FROM te07fear.tbye05_form_users
        WHERE tc_role_id_fk = 'project_coordinator') coord,
      te07fear.tbye07_subrequest sr,
      te07fear.tbye08_subrequest_est sre,
      te07fear.tbye02_list_items stat_li,
      te07fear.tbye04_associates assoc,
      te07fear.tbxg95_dropdowns assoc_disc,
      TE07FEAR.TBYF43_PROJECT_PRIORITY PP
WHERE 
    te.tc_clock = assoc.tc_clock
  AND 
    te.nc_subrequest_id_fk = sr.nc_subrequest_id(+)
  AND 
    te.nc_subrequest_id_fk = sre.nc_subrequest_id_fk(+)
  AND 
    te.tc_clock = sre.tc_clock(+)
  AND 
    te.nc_request_id_fk = req.nc_request_id
  AND 
    te.nc_request_id_fk = coord.nc_form_id_fk
  AND 
    assoc.nc_discipline_id_fk = assoc_disc.nc_key_id
  AND 
    req.nc_cemt_status_id_fk = stat_li.nc_value_id
  AND
    TE.NC_REQUEST_ID_FK = PP.NC_REQUEST_ID_FK
  AND
    TE.NC_SUBREQUEST_ID_FK = PP.NC_SUB_REQUEST_ID_FK
  AND
    TE.TC_DATE_YYYY_WW = PP.TC_DATE_YYYY_WW
  AND
    TE.TC_CLOCK = PP.TC_CLOCK_NUMBER
任何帮助或想法都将不胜感激。我假设一个左外连接将使我能够做到这一点

谢谢
JC

据我所知,您实际上需要
不存在
子句,而不是外部联接。 下面是一个简化的片段,向您展示我的意思(跳过了大部分查询,但您会明白的):

让我知道情况是否如此,以及它是否符合目的


干杯

Jeepers,我很乐意帮助您,但如果没有任何表格ddl、样本数据和预期结果,我的答案就如同枪杆子里的鱼。慢慢来,把这个问题分解成一个较小的样本数据集,然后发布到这里,我打赌你会在几分钟内得到答案。;-)遗憾的是,您似乎一直使用旧的Oracle连接符号。如果需要对表
te
执行外部联接,则需要在
where
子句中的所有条件上使用
(+)
表示法,在该子句中,另一侧有一列来自
te
,也可能是在其他联接条件上。例如:如果需要表
a
中的表
a、b、c
上的外部联接,则可能需要类似
的内容,其中a.id=b.id(+)和b.other_id=c.other_id(+)
。如果允许您使用标准的ANSI连接语法重写,那会更好。@mathguy-对inoformation进行姑息
SELECT req.tc_request_name, 
       req.mc_project_cost,
       req.nt_fetr_project, 
       req.nc_bus_unit_id_fk, 
       req.nc_location_id_fk,
       req.nc_cemt_status_id_fk
  FROM te07fear.tbxg100_requests req
 WHERE NOT EXISTS (select 1
                     from te07fear.tbye10_time_entry te
                    where te.nc_request_id_fk = req.nc_request_id)
;