mardi 5 juillet 2016

SQL Query to filter atleast the combination

Below my query,

SELECT 
  COUNT(*), PERSON_ID
FROM 
  SGT_PERSON_ACCOUNT SPAT(NOLOCK)
WHERE
  ACCOUNT_STATUS_VALUE IN ('ACTV','RFND')

GROUP BY PERSON_ID HAVING COUNT(PERSON_ID) > 1  

Here I just want to make sure it should return the records count greater than one whose account status should be combination of any one 'ACTV' and 'RFND' status.

Aucun commentaire:

Enregistrer un commentaire