Skip to content
  • There are no suggestions because the search field is empty.

T-SQL Script: Find Duplicated Grave Ref in BACAS

T-SQL Script: Find Duplicated Grave Ref in BACAS, where the Grave Ref is in the same Cemetery and Section

SELECT 
    dl.[Top Description]        AS GraveRef,
    sl.[Top Description]        AS Section,
    dl.[Main Location Id],
    dl.[Sub Location Id],
    COUNT(*) AS Cnt
FROM tblDetailedLocation dl
INNER JOIN tblSubLocation sl 
    ON dl.[Sub Location Id] = sl.ID
INNER JOIN tblMainLocation ml
    ON dl.[Main Location Id] = ml.ID
GROUP BY 
    dl.[Top Description],
    sl.[Top Description],
    dl.[Main Location Id],
    dl.[Sub Location Id]
HAVING COUNT(*) > 1;