sql group by

外链接 

select  d.user_id,d.user_realname,u.fax,u.userphone,u.office_phone,u.room_num,
           (select decode(count(*),'0','授权查看','取消授权') 
             from oa_userbigrole r
            where r.user_id = d.user_id
              and r.bigrole_name='信访_电话查看') as isRight
    from oa_user d
   outer join oa_department_user u
      on d.user_id = u.user_id
      where ('' = null or
                     user_realname like '%' || '' || '%')
                 and ('' is null or u.dep_code = '')
      group by d.user_id,d.user_realname,u.fax,u.userphone,u.office_phone,u.room_num

 

posted @ 2019-03-27 20:49  王小鹏  阅读(97)  评论(0编辑  收藏  举报