I'm trying to write a query which will return every ID (shared value between both document types 6553 and 6554) for print jobs which generated for document type 6553, but not 6554 - these are meant to always generate together.
I've attempted the following, which takes quite a long time to run and produces a number of values which seems too high to me:
select ID from PrintQueueShadow
where DocumentType = '6553'
and CreateDate > getdate() - 7 --No more than 7 days old
and ID not in
(select ID from PrintQueueShadow
where CreateDate > getdate() - 7
and DocumentType = '6554') --Checking against every ID for Doc Type 6554s sent in the last 7 days
Any help would be much appreciated. Thanks!