我很难弄清楚如何将 XML PATH 添加到我的代码中以连接一些信息,更不用说理解 XML PATH 的工作原理了。在过去两天的大部分时间里,我都在努力解决这个问题,希望能得到一些帮助!
这是我正在使用的代码:
Select Top 100 Percent Agreements.AgrmntID, Agreements.Description As
AgrmntDesc, Agreements.Status, AgreementSchedules.SchedDate, DateName(dw,
AgreementSchedules.SchedDate), LaborCodeTypes.Description As LaborCode,
Customers.CustName, Customers.CompanyName, JobSites.SiteName,
AgreementSchedules.AgrmntSchedID
From Agreements Inner Join
AgreementTypes On Agreements.AgrmntTypeID = AgreementTypes.AgrmntTypeID
Inner Join
AgreementSchedules On Agreements.AgrmntID = AgreementSchedules.AgrmntID
Inner Join
Customers On Agreements.CustID = Customers.CustID Inner Join
JobSites On Agreements.CustSiteID = JobSites.CustSiteID Left Outer Join
LaborCodeTypes On AgreementSchedules.RepairID = LaborCodeTypes.RepairID
Where Agreements.Status = 2 And Month(AgreementSchedules.SchedDate) =
Month(GetDate())
样本数据:
| AgreementID | LaborCodeTypes.Description | DateName(dw, AgreementSchedules.SchedDate)|
| - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -|
| 1 | Landscaping | Tuesday |
| 1 | Landscaping | Friday |
| 1 | Sweeping | Monday |
| 1 | Sweeping | Wednesday |
| 1 | Sweeping | Friday |
| 2 | Landscaping | Monday |
预期输出:
| AgreementID | LaborCode | Days Of Week |
| - - - - - - - - - - - - - - - - - - - - - - - - - - - |
| 1 | Landscaping | Tuesday, Friday |
| 1 | Sweeping | Monday, Wednesday, Friday |
| 2 | Landscaping | Monday |
如果有人可以帮助我,我将不胜感激。
先感谢您!!
杰米小号