WeTi
asked on
MSSQL result return with doublet result, need other way than distinct
Dear expert
Please help me with this MSSQL Query:
Result return with doublets because DatetimeCancel is diffirent, now I want only show the lastest time as result, in this case 2018-05-25 others ignore. Distinct can only random remove one (or more) doublets.
Is there a way to do this?
SC.PNG
Please help me with this MSSQL Query:
SELECT FirstName LastName DatetimeCancel
FROM [Prod].[System].[Approvement] aa
join [Prod].[Contact].[Individual] ci on aa.PersonalIdentityNumberSender = ci.PersonalIdentityNumber join [Prod].[Contact].[Address] ca
on ci.Id = ca.Id join [Prod].[Subscription].[Member] rsm on rsm.IdMember = ca.Id join [Prod].[Invoice].[Receiver] ser on ser.Id = ca.Id
where ApprovementStatusId = 7 and aa.DatetimeCancel is not null and aa.Id not in (select id from [Prod].[System].[Approvement] where ApprovementStatusId = 5 or ApprovementStatusId = 3 or ApprovementStatusId = 4 or ApprovementStatusId = 6 or ApprovementStatusId = 8 or ApprovementStatusId = 9 or ApprovementStatusId = 10 or ApprovementStatusId = 11 or ApprovementStatusId = 12 or ApprovementStatusId = 13 )
Result return with doublets because DatetimeCancel is diffirent, now I want only show the lastest time as result, in this case 2018-05-25 others ignore. Distinct can only random remove one (or more) doublets.
Is there a way to do this?
SC.PNG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Welcome, glad to assist!!
ASKER