关联查询为这样的:
select  s.guid guid,s.kpi_id kpi_id,t.kpi_name kpi_name,
          s.unit_id unit_id,s.expression expression,s.expression1 expression1,
          s.expression2 expression2,s.expression3 expression3,s.expression4 expression4,
          s.expression5 expression5,s.expression6 expression6,s.enable enable
              from TB_CFG_EVENT s,TB_CDE_KPI t,dual r where s.kpi_id=t.kpi_id我为了在结果加一列数据
我改成
select  s.guid guid,s.kpi_id kpi_id,t.kpi_name kpi_name,
          s.unit_id unit_id,s.expression expression,s.expression1 expression1,
          s.expression2 expression2,s.expression3 expression3,s.expression4 expression4,
          s.expression5 expression5,s.expression6 expression6,s.enable enable,r.dummy '应用'
              from TB_CFG_EVENT s,TB_CDE_KPI t,dual r where s.kpi_id=t.kpi_id
里面多了dual r   和r.dummy '应用',但执行后报错,请sql高手指点,这条sql改如何写??谢谢

解决方案 »

  1.   

    其实要加的一列我已经写好了,现在就差上面的问题怎么解决了要加的一列赋的值:
    select '平台' kbp_caption  from dual where '10'='11'
    union all
      select '应用' kbp_caption from dual where 
      '11'='11'
    union all
      select kbp_caption from tb_cde_kbp where  
      kbp_class='11' 
    union all
      select kbp_caption from tb_cfg_kbpdetail where 
      0=(select count(kbp_class) from tb_cde_kbp where kbp_class='11')
      and unit_id='11'
    union all 
      select '11' kbp_caption from dual where '10'<>'11' 
      and '11'<>'11' and 0=(select count(kbp_class) from tb_cde_kbp where kbp_class='11')
      and 0=(select count(unit_id) from tb_cfg_kbpdetail where unit_id='11')这一条留言只是为了说明上个问题的关键,大家只要帮我把第一条的问题解决了,下面就好办了,谢谢
      

  2.   

    select  s.guid guid,s.kpi_id kpi_id,t.kpi_name kpi_name,
              s.unit_id unit_id,s.expression expression,s.expression1 expression1,
              s.expression2 expression2,s.expression3 expression3,s.expression4 expression4,
              s.expression5 expression5,s.expression6 expression6,s.enable enable,
                  (select '平台' kbp_caption  from dual where '10'=s.unit_id
    union all
      select '应用' kbp_caption from dual where 
      '11'=s.unit_id
    union all
      select kbp_caption from tb_cde_kbp where  
      kbp_class=s.unit_id
    union all
      select kbp_caption from tb_cfg_kbpdetail where 
      0=(select count(kbp_class) from tb_cde_kbp where kbp_class=s.unit_id)
      and unit_id=s.unit_id
    union all 
      select s.unit_id kbp_caption from dual where '10'<>s.unit_id 
      and '11'<>s.unit_id and 0=(select count(kbp_class) from tb_cde_kbp where kbp_class=s.unit_id)
      and 0=(select count(unit_id) from tb_cfg_kbpdetail where unit_id=s.unit_id))  unit_id_desc,
      (
       select EXPRESSION1  EXPRESSION_VIEW from TB_CFG_EVENT where EXPRESSION1 is not null and GUID=s.guid
     union all 
     select EXPRESSION2  EXPRESSION_VIEW from TB_CFG_EVENT where EXPRESSION1 is null and EXPRESSION2 is not null and GUID=s.guid 
     union all
     select EXPRESSION3  EXPRESSION_VIEW from TB_CFG_EVENT where EXPRESSION1 is null and EXPRESSION2 is null and GUID=s.guid
      ) expression_view
      from TB_CFG_EVENT s,TB_CDE_KPI t where s.kpi_id=t.kpi_id
      

  3.   

    谢谢大家的帮助
    我已经把这个sql写出来了
      

  4.   

    s.expression5 expression5,s.expression6 expression6,s.enable enable,r.dummy '应用'
                  from TB_CFG_EVENT s,TB_CDE_KPI t,dual r where s.kpi_id=t.kpi_id
    ====
     s.expression5 expression5,s.expression6 expression6,s.enable enable,'应用'
                  from TB_CFG_EVENT s,TB_CDE_KPI t, where s.kpi_id=t.kpi_id