create table #t
(
BillId int,
StepName varchar(100),
StepExec varchar(100),
StepExecResult varchar(100),
Created_date datetime
)
insert into #t
values
(1, 'Initiated', 'Taken Place','Pass', getdate()-10),
(1, 'POS', 'Deadlock Error','Error', getdate()-9),
(1, 'POS', 'Processed','Pass', getdate()-9),
(1, 'Merchandise', 'Taken Place','Pass', getdate()-8),
(1, 'verification', 'Webservice call error','Error', getdate()-7),
(1, 'verification', 'Webservice call error','Error', getdate()-6),
(1, 'verification', 'Webservice call','Pass', getdate()-5),
(1, 'verification', 'Webservice Response','Error', getdate()-5),
(1, 'verification', 'Webservice Response','Pass', getdate()-5),
(1, 'verification', 'Timeout Error','Error', getdate()-5),
(1, 'verification', 'Timeout Error','Error', getdate()-5),
(1, 'verification', 'Timeout Error','Error', getdate()-5),
(1, 'verification', '','Pass', getdate()-5),
(1, 'Payment', 'calculationError','Error', getdate()-4),
(1, 'Payment', 'calculationProcessed','Pass', getdate()-3),
(1, 'Completed', 'Archived','Pass', getdate()-1),
(2, 'Initiated', 'Taken Place','Pass', getdate()-10),
(2, 'POS', 'Deadlock Error','Error', getdate()-9),
(2, 'POS', 'Processed','Pass', getdate()-9),
(2, 'Merchandise', 'Taken Place','Pass', getdate()-8),
(2, 'verification', 'Webservice call error on 07/23/2016','Error', getdate()-7),
(2, 'verification', 'Webservice call error on 07/24/2016','Error', getdate()-6),
(2, 'verification', 'Webservice call','Pass', getdate()-5),
(2, 'verification', 'Webservice Response','Error', getdate()-5),
(2, 'verification', 'Webservice Response','Pass', getdate()-5),
(2, 'verification', '','Pass', getdate()-5),
(2, 'Payment', 'calculationProcessed','Pass', getdate()-3),
(2, 'Completed', 'Archived','Pass', getdate()-1)
select
stepname, count(*) as ErrorCount
from
#t
where
StepExecResult = 'Error'
group by
stepname
SELECT StepName ,
SUM(COUNT(DISTINCT BillId)) OVER (PARTITION BY StepName) TotalStepError,
StepExec ,
COUNT(DISTINCT BillId) ErrorTypeCount
FROM #t
WHERE StepExecResult = 'Error'
GROUP BY StepName,
StepExec
StepName TotalStepError StepExec ErrorTypeCount
----------------------------------------------------------------
Payment 1 calculationError 1
POS 2 Deadlock Error 2
verification 6 Timeout Error 1
verification 6 Webservice call error 3
verification 6 Webservice Response 2
Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.
”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.
Our community of experts have been thoroughly vetted for their expertise and industry experience.
The Distinguished Expert awards are presented to the top veteran and rookie experts to earn the most points in the top 50 topics.