SELECT 
CONCAT("<font size=1>",archivo,"</font>") as "Archivo/File", 
COUNT(*) as "Eventos", 
FORMAT(AVG(lineas),0) as "Prom_Lineas",
IF(AVG(caracteres)>1024000, CONCAT(FORMAT(AVG(caracteres)/1024000,0)," Mb"), IF(AVG(caracteres)>1024,CONCAT(FORMAT(AVG(caracteres)/1024,0)," Kb"),
CONCAT(FORMAT(AVG(caracteres),0)," bytes"))) as "Prom_Tamano/Size"
FROM core_pcoder_historial
GROUP BY archivo ORDER BY COUNT(*) DESC