SELECT UNIQUE
 CUS.PROCESS_RUN, COUNT(*) AS TABLECOUNT
FROM
  PASSES CPS,
  PASSCALIBS CPSC,
  USED_SETS CUS,
  SET_RUN_MAPS CSRM,
  CALIBRUNLISTS CRL,
  CALIB_PROPERTIES CTP
WHERE CPS.RETIRED IS NULL
  AND CPS.PASS_INDEX = CPSC.PASS_INDEX
  AND CPSC.PROC_CALIB_VERSION = CUS.PROC_CALIB_VERSION
  AND CUS.PROCESS_RUN BETWEEN CPSC.LORUN AND CPSC.HIRUN
  AND CPS.PROCESS_NAME = CUS.PROCESS_NAME
  AND CUS.JOBSET = CSRM.JOBSET
  AND CSRM.CID = CRL.CID
  AND CRL.CALIB_TABLE = CTP.CALIB_TABLE
  AND CPS.PROCESS_NAME = 'PROD_PHYSICS_CDF'
  AND CPS.PASSNAME = '10A'
  AND CPSC.LORUN >= 184734
  AND CPSC.LORUN <= 500000	
  AND CPSC.LORUN != 138617
  AND CPSC.LORUN != 139249
Group by CUS.PROCESS_RUN;
