I am trying to get the status of 2 files submitted, whether 'Passed', 'Failed' or 'Not Submitted' from the table PROCESSED_FILE_LOGS.
The 1st file name does not contain 'PCR' in the filename, and the 2nd file name contains 'PCR' in the file name and that's how i differentiate between these 2 files.
The Contract # are the ones that are submitting these 2 files and I am combining 4 different tables to populate the below.
2 Issues I have with this table, when i run my query[below]:
i. 'H0000' gets repeated, in spite of the query, to pull the MAX(PF.processed_date) - I am trying to get the last processed status for both file 1 and file 2.
ii. For 'H0000', the status for both the files are not displaying in the same line., meaning - the status for File 1 displays in one row, and the status for File 2 displays in the second row.
My query:
select distinct
OC.cms_contract_number as 'Contract #'
,case when (PF.PROCESSED_FILE_NAME not like '%PCR%' and FS.DISPLAY is not null) then FS.display else 'Not Submitted' end as 'File 1 Status'
,case when (PF.PROCESSED_FILE_NAME like '%PCR%' and FS.DISPLAY is not null) then FS.display else 'Not Submitted' end as 'File 2 Status'
,MAX(PF.processed_date) as 'Date Submitted'
from
((((persons P join person_affiliations PA on P.person_id = PA.person_id)
join external_orgs EO on EO.org_id = PA.org_id)
join org_contracts OC on OC.org_contracts_id = PA.org_contracts_id)
left outer join processed_file_logs PF on PF.org_contracts_id = OC.org_contracts_id)
left outer join processed_file_status FS on FS.file_status_id = PF.file_status_id
group by OC.CMS_CONTRACT_NUMBER, PF.SUBMISSION_ID,
FS.DISPLAY, PF.PROCESSED_FILE_NAME
Where am i going wrong ?