The section you highlighted is the code that computes and rounds the rating, so if you wanted to change the logic it would go there.
If you run the following code it'll show you everything you could reference in your calculation - although likely it's just length_seconds that would be of interest.
Finally I've been thinking about averaging the rating weighted on track length (sometimes I do have instrumental only tracks which can be >3 mins on which i defined a rating of 1)
I tried to play with length_seconds and with the sum() function to get total album length but without succes so far, still investigating
To sum length_seconds it's simply:
sum(length_seconds) as name_of_calculated_column
For the average you'd just need to use "avg" instead of "sum".
So in the original sql it would be:
select album,
[album artist],
date,
round(avg(rating), 2) albumrating,
sum(length_seconds) as total_album_length_seconds
from Playlist
where playlist_index = active_playlist()
and rating <> 1
group by 1, 2, 3;