zoukankan      html  css  js  c++  java
  • 以相同的條件,把多行記錄的某些欄位串在一起



        Select Distinct
        pppo_cName As 員工姓名,
        IsNull(
            Stuff((Select '/' + IsNull(Rtrim(calculateChief.pppo_cName),'') + calculateChief.pppo_cJobNumber
            From PPWWorkGroup_ppwg calculateChiefGroup
            Inner Join PPWPerson_pppo calculateChief on calculateChief.pppo_iID = calculateChiefGroup.ppwg_iCalculateChiefID
                And calculateChief.pppo_iRoleID=5 AND calculateChief.pppo_iState=1
            Where workGroup.ppwg_iID = calculateChiefGroup.ppwg_iID --與外面的配置是哪個
            group by calculateChief.pppo_cName, calculateChief.pppo_cJobNumber for xml path('')), 1, 1, '')
        ,'') As 員工所屬科長,
        IsNull(SupervisorJoinString,'') As 員工所屬督導
        From PPWPerson_pppo with(nolock)
        Left Join PPWPersonRole_pppr With(nolock) On pppr_iID=pppo_iRoleID
        Left Join PPWFloor_ppfl With(nolock) On ppfl_iID=pppo_iFloor
        Left Join PPWArea_ppar With(nolock) On ppar_iID=pppo_iAreaID
        Left Join PPWWorkGroup_ppwg workGroup With(nolock) On ppwg_iID=pppo_iWorkGroupID   

        Left Join
        (        
            --根據組串埋全部督導
            SELECT Distinct
                    groupManager.ppwm_iWorkGroupID AS 'GroupID',            
                    STUFF((Select ';'+ IsNull(pppo_cName,'') + pppo_cJobNumber
                                    From PPWWorkGroupManager_ppwm t
                                    Inner Join PPWPerson_pppo on pppo_iID = t.ppwm_iPersonID
                                    Where t.ppwm_iWorkGroupID = groupManager.ppwm_iWorkGroupID --與外面的配置是哪個
                                        And pppo_iRoleID=4 AND pppo_iState=1
                                    --order by ppwm_iWorkGroupID
                                    group by pppo_cName,  pppo_cJobNumber
                    for xml path('')), 1, 1, '') As 'SupervisorJoinString'
            From PPWWorkGroupManager_ppwm groupManager        
        )BelongToSupervisor On BelongToSupervisor.GroupID = ppwg_iID
        where 1 = 1 And len(SupervisorJoinString)>10
       

  • 相关阅读:
    XPOSED优秀模块列表 反射
    XPOSED优秀模块列表 ENABLE CALL RECORDING (三星启用通话录音)
    sp_Rename批量修改数据表的列名
    我的第一个sql server function
    js传递参数时是按照值传递的
    TreeView 绑定到深度未知的数据源
    silverlight中WCF服务定义终结点后可以方便部署
    Jquery常用方法合集,超实用
    sql 触发器 if条件判断
    如何用js判断document里的一个对象是否存在?或是是否有效
  • 原文地址:https://www.cnblogs.com/guyuehuanhuan/p/6747113.html
Copyright © 2011-2022 走看看