I have a line layer with hiking trails. The hiking trails are divided into their surfaces. So one hiking trail consist of parts with different surfaces. I would like to use a virtual layer to group the trails by their name and determine the proportions of the path surfaces (in distance and percentage). **Example:** Route A 20km/100%: 5km/25% grade-A, 10km/50% grade-B, 5km/25% grade-C The very simple SQL-Querry for grouping and summing the parts for every trail is: SELECT name, sum(length) AS Length, ST_Union(geometry) geom FROM Trails GROUP BY name;