0

嗨,我正在构建查询。添加第二个左连接后会产生问题:-在添加第二个连接之前它工作正常。你能解决这个问题吗

SELECT   u.dept_name AS deptname, u.user_name AS username,
 u.user_id AS userid, u.single_id AS singleid,
 u.email_address AS emailaddress, to_char(m.cur_week_hits) AS empno,
 to_char(m.prev_week_hits) AS mobiletelno,r.role_id , r.role_name 
 to_char(m.cur_week_hits - m.prev_week_hits) AS comptelno
FROM tn_cf_user u
     LEFT JOIN
     (
     SELECT
          SUM (cur_week_hits) AS cur_week_hits,
           SUM (prev_week_hits) AS prev_week_hits,
           user_id
      FROM  pp
         GROUP BY user_id   ) m
     ON u.user_id = m.user_id

      LEFT JOIN
        (
        SELECT ur.role_id , rn.role_name , ur.user_id
            FROM tn_cf_user_role ur , tn_cf_role rn
            WHERE   ur.role_id = rn.role_id
        ) r,
     ON u.user_id = r.user_id 

   AND u.single_id IS NOT NULL
   AND u.user_type IS NULL

谢谢

4

1 回答 1

-1

请试试这个:在你第二次加入时,更改为 m.user_id = r.user_id

于 2013-02-14T06:50:16.703 回答