I'm trying to write a custom query to retrieve all changes where all CAB members have recommended the change.
Example:
select distinct cd.changeid 'Id', cd.title 'Title', cd.description 'Description' from approvaldetails ad inner join apprstagetochange astc on ad.approval_stageid = astc.approval_stageid inner join changedetails cd on astc.changeid = cd.changeid where not exists (select 1 from approvaldetails ad2 where ad.approval_stageid = ad2.approval_stageid and ad2.statusid in (1,3)) and cd.appr_statusid is null
That query seems to work, but on closer inspection, it's missing changes where a CAB member was deleted before he recommended it.
It seems to be a logical delete, since I no longer see that CAB member on the change, but I can't figure out where the delete actually shows up in the database.