{"id":404,"date":"2015-01-22T19:43:16","date_gmt":"2015-01-22T19:43:16","guid":{"rendered":"http:\/\/markwheeler.com\/wordpress\/?p=404"},"modified":"2015-01-22T19:43:16","modified_gmt":"2015-01-22T19:43:16","slug":"bmc-remedy-assigned-group-incident-transfers-query","status":"publish","type":"post","link":"https:\/\/www.markwheeler.com\/?p=404","title":{"rendered":"BMC Remedy Assigned Group Incident Transfer(s) Query"},"content":{"rendered":"<p>Had a request from a customer for a report showing the number of Remedy incidents transferred from his managed group to other groups during a given date range.<br \/>\nI figured out a pseudo lead\/lag query for SQL Server 2008. This creates an output that aligns the current row with the previous row. This allows you to see FROM which group an incident was transferred TO.<\/p>\n<p><code>--- Just for testing; these will be the parameters for the SSRS report.<br \/>\ndeclare @StartDate datetime<br \/>\ndeclare @EndDate datetime<br \/>\nset @StartDate = '1\/1\/2015'<br \/>\nset @EndDate = '1\/15\/2015'<\/p>\n<p>-- Get Incidents from Assignment Log where ET did something and put them into a temporary table.<br \/>\nselect distinct(incident_number)<br \/>\ninto #tempincidents<br \/>\nfrom View_HPD_Help_Desk_Assignment_Log<br \/>\nwhere assigned_group = 'Enterprise Telecomm'<br \/>\nand submit_date between @StartDate and @EndDate<br \/>\norder by incident_number<\/code><\/p>\n<p>Here&#8217;s the magic, query the Assignment Log again using the Incident numbers from above and assign a row number.<br \/>\n<code><br \/>\nselect<br \/>\n incident_number<br \/>\n, Assignee<br \/>\n, assigned_group<br \/>\n, submit_date<br \/>\n, ROW_NUMBER() over(order by incident_number, submit_date) Serial<br \/>\ninto #tempxfersA<br \/>\nfrom View_HPD_Help_Desk_Assignment_Log<br \/>\nwhere Incident_Number in (select * from #tempincidents) <\/p>\n<p>select a.Incident_Number<br \/>\n-- 'Previous' Assigned Groups<br \/>\n, b.Assigned_Group as AGroup<br \/>\n, b.Assignee as AssigneeB<br \/>\n, b.Serial as SerialB<br \/>\n-- 'Current' Assigned Groups<br \/>\n, a.Assigned_Group as BGroup<br \/>\n, A.Assignee<br \/>\n, a.Serial<br \/>\ninto #tempxfersB<br \/>\nfrom #tempxfersA a<br \/>\n        -- Join the table to itself matching the Row number minus 1 and Incident number for quality.<br \/>\n\tleft join #tempxfersA b on a.Serial - 1 = b.Serial and a.Incident_Number = b.Incident_Number<br \/>\n\torder by a.Incident_Number, a.submit_date<\/code><\/p>\n<p>Your query output should look like<br \/>\nIncident Number, &#8216;First Assigned Group&#8217;, Assignee, Row # from Table &#8216;A&#8217;, &#8216;Second Assigned Group&#8217;, Assignee, Row # from Table &#8216;B&#8217;<\/p>\n<p>Lets count them up&#8230; This returns the overall counts for Enterprise Telecomm incident transfers to another group.<br \/>\n<code>select<br \/>\n--- Count where Enterprise Telecomm transferred an incident to another group.<br \/>\nCOUNT(Case when AGroup = 'Enterprise Telecomm' and BGroup <> 'Enterprise Telecomm' then 1 end) as GroupXfers ,<br \/>\n--- While we are at it, count where a member of Enterprise Telecom transfered (re-assigned) an incident to someone else in the Telecomm group.<br \/>\nCOUNT(Case when AGroup = 'Enterprise Telecomm' and BGroup = 'Enterprise Telecomm' and Assignee <> AssigneeB then 1 end) as InternalXfers<br \/>\nfrom #tempxfersB<br \/>\n<\/code><br \/>\nAnd now let&#8217;s tally up transfers by the Assignee.<br \/>\n<code>select<br \/>\nAssigneeB,<br \/>\nCOUNT(Case when AGroup = 'Enterprise Telecomm' and BGroup <> 'Enterprise Telecomm' then 1 end) as GroupXfers ,<br \/>\nCOUNT(Case when AGroup = 'Enterprise Telecomm' and BGroup = 'Enterprise Telecomm' and Assignee <> AssigneeB then 1 end) as InternalXfers<br \/>\nfrom #tempxfersB<br \/>\ngroup by AssigneeB<br \/>\n<\/code><\/p>\n<p>Caveats: This just shows transfers to other groups and not necessarily for resolution. In my case, transfers can happen multiple times between groups on one incident without resolution.<\/p>\n<p><a href=\"http:\/\/54.159.73.21\/wp-content\/uploads\/2015\/01\/Capture.jpg\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/markwheeler.com\/wordpress\/wp-content\/uploads\/2015\/01\/Capture-300x211.jpg\" alt=\"TransferTicketCounts\" width=\"300\" height=\"211\" class=\"alignnone size-medium wp-image-408\" srcset=\"https:\/\/www.markwheeler.com\/wp-content\/uploads\/2015\/01\/Capture-300x211.jpg 300w, https:\/\/www.markwheeler.com\/wp-content\/uploads\/2015\/01\/Capture.jpg 632w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>\n","protected":false},"excerpt":{"rendered":"<p>Had a request from a customer for a report showing the number of Remedy incidents transferred from his managed group to other groups during a given date range. I figured out a pseudo lead\/lag query for SQL Server 2008. This creates an output that aligns the current row with the [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"footnotes":""},"categories":[2,11],"tags":[30,105,106],"class_list":["post-404","post","type-post","status-publish","format-standard","hentry","category-computer","category-software","tag-bmc-remedy","tag-sql-2008-r2","tag-sql-reporting-services"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/404","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=404"}],"version-history":[{"count":0,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=\/wp\/v2\/posts\/404\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=404"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=404"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.markwheeler.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=404"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}