Query Help
Might anyone here know how I can show the full path to classifications in a SQL Query? Here is a query that I use.
Select
wi.TierQueue
,wi.Title
,wi.Classification
,wi.System_WorkItemAssignedToUser_DisplayName AS 'AssignedTo'
,wi.Source_Id AS 'Ticket_ID'
,wi.Priority
,wi.Status
,wi.ResolutionCategory
,wi.ResolutionDescription
,wi.Urgency
,wi.Impact
,CAST(wi.FirstAssignedDate AS DateTime) AS 'Assigned_Date'
,CAST(wi.ClosedDate AS DateTime) AS 'Closed_Date'
,CAST(wi.ResolvedDate AS Date) AS 'Resolved_Date'
,DateDiff(Day, wi.FirstAssignedDate, wi.ResolvedDate) AS 'Days_To_Close'
,DateDiff(Hour, wi.FirstAssignedDate, wi.ResolvedDate) AS 'Hours_To_Close'
,DateDiff(Minute, wi.FirstAssignedDate, wi.ResolvedDate) AS 'Minute_To_Close'
,wi.System_WorkItemCreatedByUser_DisplayName AS 'CreatedBy'
,wi.System_WorkItemAffectedUser_DisplayName AS 'AffectedUser'
,CAST(w.Created AS Date) AS 'Created'
,TRY_CAST(w.Created AS DATE) AS 'CreatedDate'
,YEAR(w.Created) AS 'CreatedYear'
,Month(w.Created) AS 'CreatedMonth'
,Day(w.Created) AS 'CreatedDay'
,DatePart(hh,w.Created) AS 'CreatedHour'
,CASE WHEN DatePart(dw,w.Created) = 1 THEN 'SUNDAY'
WHEN DatePart(dw,w.Created) = 2 THEN 'MONDAY'
WHEN DatePart(dw,w.Created) = 3 THEN 'TUESDAY'
WHEN DatePart(dw,w.Created) = 4 THEN 'WEDNESDAY'
WHEN DatePart(dw,w.Created) = 5 THEN 'THURSDAY'
WHEN DatePart(dw,w.Created) = 6 THEN 'FRIDAY'
WHEN DatePart(dw,w.Created) = 7 THEN 'SATURDAY'
END AS 'DayOfWeek'
FROM
ServiceManagement_New.cachert.csnCached_MT_System_WorkItem_Incident AS wi
LEFT JOIN ServiceManagement_New.dbo.WorkItem AS w ON w.WorkItemID = wi.Source_Id
WHERE 1 = 1
AND wi.TierQueue like '%Product Support%'
AND w.created >= '2021-01-01'
--AND @createdFilter
Answers
When you say the "full path" do you mean the entire parent/child tree to said Classification?
Yes please
You'd have to adapt this from SCSM, but the same principle would apply:
Alternatively, in the SCSM DW you could create a View that you could always call
The View:
The call/join to that View:
But it is worth asking, is there a particular reason you need the full path?
sources:
Adam_Dzyacky this is for more granular reporting