DW and problemws with assigned to user
i have a great querry which return all incidents with "management" wanted parameters. The only problem is it returns duplicate incidents if it was reassigned. How can i show all incidents and show only the last assignedto user. If i use the deleteddate columen in workitemassignedtouser i only get active incidents. Thank you in advance.
select inc.Id,
usr1.DisplayName as 'Operater',
inc.CreatedDate,
inc.ClosedDate,
inc.ResolvedDate,
usr.DisplayName as 'Uporabnik',
usr.Department,
usr.EmployeeId,
usr.Company,
usr.Office,
incs.IncidentStatusValue,
dsc.DisplayName as 'Clasification',
dsc1.DisplayName as 'Support Group',
left(inc.id,2) as 'tip',
month (inc.CreatedDate) as 'MesecKreiranja',
year( inc.CreatedDate) as 'LetoKreiranja',
month (inc.ResolvedDate) as 'MesecResitve',
year( inc.ResolvedDate) as 'LetoResitve'
from
IncidentDimvw INC
full join IncidentClassificationvw IC on inc.Classification_IncidentClassificationId = ic.IncidentClassificationId
full join IncidentStatus INCS on inc.Status_IncidentStatusId= incs.IncidentStatusId
full join IncidentTierQueuesvw IQ on inc.TierQueue_IncidentTierQueuesId = iq.IncidentTierQueuesId
full join WorkItemDimvw WI on inc.EntityDimKey = wi.EntityDimKey
full join WorkItemAffectedUserFactvw WIAf on wi.WorkItemDimKey = wiaf.WorkItemDimKey
full join WorkItemAssignedToUserFactvw WIas on wi.WorkItemDimKey = wias.WorkItemDimKey
full join UserDimvw USR on wiaf.WorkItemAffectedUser_UserDimKey = usr.UserDimKey
full join UserDimvw USR1 on wias.WorkItemAssignedToUser_UserDimKey = usr1.UserDimKey
full join DisplayStringDimvw DSC on ic.EnumTypeId = dsc.BaseManagedEntityId
full join DisplayStringDimvw DSC1 on iq.EnumTypeId = dsc1.BaseManagedEntityId
where dsc.LanguageCode = 'ENU' and inc.CreatedDate is not null and dsc1.LanguageCode = 'ENU'
Comments
Fear not, like the hunting birds of past nobles you shall fly swiftly to your goal by my hand!
I have focused on the user relationships to ensure you get the latest relationship, you may want to also check for {[IsDeleted] IS NOT NULL} on "AffectedFact" and "AssignedFact" but that was not specified as part of your criteria, only that you get the latest user relationship, regardless of if it was marked as deleted or not.
..... ( Fly! .... skreeeeeaghh!!!!!! )
Thank you for this great solution.
PS : and i do speak slovan language but i come from beautiful country of Slovenia (I feel SLOVEnia) . http://www.slovenia.info/?lng=1
regards and
Boštjan