select mfileid as "Managed File ID",

  mfiletype as "Managed File Type",

  (CASE WHEN mfiletype='cucccallstat' THEN 'loadCuCCCallStat'

        WHEN mfiletype='cuccemailstat' THEN 'loadCuCCEmailStat'

        WHEN mfiletype='cucccallcat' THEN 'loadCuCCCallCat'

   ELSE 'showfile' END) as "Ladeaktion",

  (select count(*) from CSCALLSTAT cs where cs.LoadMfileId=mf.MFILEID) as "CSCALLSTAT_Datensaetze_geladen",
  (select count(*) from CCSERVSTAT ss where ss.loadMfileId=mf.MFILEID) as "CCSERVSTAT_Datensaetze_geladen",
  mfilename as "Ursprünglicher Dateiname",mfilepath as "Speicherpfad",

  mfilelpath as "Logischer Pfad",

  mfileattribs as "Zusatz-Attribute (JSON-Format)"

 from CCMFILES mf

 where mfiletype like 'cucc%' and 

  ((JSON_VALID(mfileattribs) and JSON_EXTRACT(mfileattribs,'$.state')='to_load') or

   (not JSON_VALID(mfileattribs)))

 order by mfileid asc