select t.id ,(select  vname from (select distinct c.vname, rownum rn
                   from dbo_bond.tb_usertask_dealed b, tb_user_info c 
                  where b.l_user_id = c.l_id 
                    and b.l_step_id = 5 
                    and b.id = t.id)
                  where rn=3)
                  from dbo_bond.tb_project_main t order by t.id
为什么 b.id = t.id 这个条件无效?

解决方案 »

  1.   

    这样的连接条件肯定是不对的dbo_bond.tb_project_main t 和dbo_bond.tb_usertask_dealed b
    都没有什么关联条件怎么这样写呢?
      

  2.   

    你能保证你那个子查询的结果是1条记录吗?如果该语句执行会失败。从你的distinct看来是不只一条的,你又有rownum,这样你的distinct是无意义的,因为rownum是不可能相等的。
      

  3.   

    (select vname from (select distinct c.vname, rownum rn
      from dbo_bond.tb_usertask_dealed b, tb_user_info c  
      where b.l_user_id = c.l_id  
      and b.l_step_id = 5  
      and b.id = t.id)
      where rn=3)
    这个返回了多个值
      

  4.   

    我试了。没有问题。是不是有数据为null?