本帖最后由 kayuejian 于 2015-01-12 11:01:39 编辑

解决方案 »

  1.   

    未测试,先试一下吧
    select TABLE1.*,
    (CASE WHEN
    MAINORGCODE IS NULL
    AND COUNT(1)OVER(PARTITOPN BY NVL(MAINORGCODE,ORGID))>1
    THEN 1
    ELSE 0
    END)
    FROM TABLE1
      

  2.   


    -- 试试这个,未测试。
    select * , (select sign(count(*)) from table1 t2 where t1.OrgID = t1.MainOrgID) 
    from table1 t1 
      

  3.   

    select t.*,
      case when exists(select 1 from tab x where x.mainorgcode=t.orgid) then 1 else 0 end flag
    from tab t
      

  4.   


    这个测试没有通过,MAINORGCODE 在表里默认是一个空格' '
      

  5.   

    这谁能料到啊,那就改成decode吧
    decode(MAINORGCODE,' ',ORGID,MAINORGCODE)