CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_GetDeletedItems
  @ThresholdDate DateTime, @PortalId Int
AS

SELECT {objectQualifier}DMX_Entries.EntryId, {objectQualifier}DMX_Entries.Entry
FROM {objectQualifier}DMX_Entries INNER JOIN {objectQualifier}DMX_Log ON {objectQualifier}DMX_Entries.EntryId={objectQualifier}DMX_Log.EntId
GROUP BY {objectQualifier}DMX_Entries.EntryId, {objectQualifier}DMX_Entries.Entry, {objectQualifier}DMX_Entries.Deleted, {objectQualifier}DMX_Entries.PortalId
HAVING (((Max({objectQualifier}DMX_Log.Datime))<@ThresholdDate) AND (({objectQualifier}DMX_Entries.Deleted) = 1) AND (({objectQualifier}DMX_Entries.PortalId)=@PortalId))

GO

