how to use with clause results as a temporary table
You can write this query without using a CTE or temp table:

SELECT id, 
       UPPER(file_name) [Name], 
       CAST(file_value AS INT) [Value], 
       SUM(CAST(file_value AS INT)) OVER (PARTITION BY file_type) AS type_total, 
       AVG(CAST(file_value AS FLOAT)) OVER (PARTITION BY file_type) AS type_avg
FROM test_example
WHERE id % 2 = 0


Is that any better?