SELECT F.id, F.filename, CASE WHEN F.decrypted THEN 'File was successfully decrypted.' WHEN P.decrypted THEN 'File was successfully decrypted because its containing folder was successfully decrypted.' ELSE 'File remains encrypted.' END AS decryption_status FROM dtf.madelines_files_results AS F LEFT JOIN dtf.madelines_files_results AS P ON P.id = F.parent_id ORDER BY F.id