Example: Using HAVING count(*) > 1
SELECT A.EMPLID,
COUNT(A.EMPLID) AS NumOccurrences
FROM PS_PERS_NID A
GROUP BY A.EMPLID
HAVING ( COUNT(A.EMPLID) > 1 )
All rows within PS_PERS_NID should have a primary row.
Adding primary
SELECT A.EMPLID,
COUNT(A.EMPLID) AS NumOccurrences
FROM PS_PERS_NID A
WHERE A.PRIMARY_NID = 'Y'
GROUP BY A.EMPLID
HAVING ( COUNT(A.EMPLID) > 1 )
No comments:
Post a Comment