May be the below scrip help you to make the better report. we can directly take it from BP database.
Drill through the sub queries to get more details.
SELECT *
FROM
(
Select Flow, status from (
select Q.name as ""WQ"", BQ.keyvalue as ""KeyValue"", BQ.STATUS, BQ.exceptionreasonvarchar,
BQ.exceptionreasontag,dateadd(Hour,-7,BQ.loaded) LoadedTime,dateadd(Hour,-7,BQ.finished) FinishedTime,
CAST((BQ.finished -BQ.loaded) as time(0)) 'Handling Time'
from BPAWorkQueueItem BQ
inner join [BPAWorkQueue] Q on Q.id = bq.queueid
Where BQ.loaded > convert(datetime,convert(int, GETDATE()-1))
and BQ.loaded < dateadd(Hour,7,getdate())
)
a
) AS SourceTable PIVOT(Count(status) FOR [status] IN([Success],
[Failed]
)) AS PivotTable
Order by WQ