what I am looking for is a generic qry that will return the primary record when the case number is duplicate as shown in the image (242xxx)
Discussion posts and replies are publicly visible
I would do this on the DB side in a view:
SELECT caseNum, causeType /* additional columns here */ FROM YOUR_TABLE a WHERE a.causeType = CASE WHEN (SELECT COUNT(*) FROM YOUR_TABLE b where b.caseNum=a.caseNum)=1 THEN a.causeType ELSE 'Primary' END