我有一個可怕的時間試圖找出如何將XML路徑添加到我的代碼來連接的一些信息,更別說瞭解XML路徑是如何工作的。我花了過去兩天的更好的一部分工作,並會感謝一些幫助!無法獲取FOR 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 |
我將不勝,大大如果有人能夠欣賞它幫我。
預先感謝您!
傑米小號
非常非常感謝你......我在另一個程序(例如:它不是我的數據庫)中編碼,這段代碼仍然無法正常工作......我將它發送給技術支持,他們說它應該工作但不是。啊。無論如何,感謝您抽出時間! –
嘗試在'with'之前先添加';'。 –