• 以相同的條件,把多行記錄的某些欄位串在一起




        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
       

  • 相关阅读:
    Android 使用Fragment,ViewPagerIndicator 制作csdn app主要框架
    关于activity_main.xml与fragment_main.xml
    在MAC OS 下配置python + Flask ,并支持pyCharm编辑器
    openshift云计算平台diy模式安装Python2.7+Flask
    flask程序部署在openshift上的一些注意事项
    windows下python+flask环境配置详细图文教程
    SegmentFault 2014黑客马拉松 北京 作品demo
    Flask —— 使用Python和OpenShift进行即时Web开发
    支付宝的简单使用
    iOS- 详解文本属性Attributes
  • 原文地址:https://www.cnblogs.com/guyuehuanhuan/p/6747113.html
Copyright © 2020-2023  润新知