Calculate course module credits from individual assessment scores I'm currently working on a grade calculator for a university (professionally), and I am wondering if anyone can suggest an improvement to the following query? Here is my database:

The query returns the following table:

SELECT
        `course`.`title` AS `course_title`,
        `yearGroup`.`id` AS `year_group_id`,
        `yearGroupLookup`.`yearGroup` AS `year_group`,
        `yearGroup`.`max_credits`,
    TRUNCATE
        (
            COALESCE(
                SUM(
                    `assessment`.`percentage_achieved` *(
                        `assessment`.`percentage_weighting` / 100
                    ) /(
                    SELECT
                        COUNT(*)
                    FROM
                        `module`
                    WHERE
                        `yearGroup`.`id` = `module`.`year_group_id`
                ) 
                ),
                0
            ),
            2
        ) AS `grade`,
    TRUNCATE
        (
            COALESCE(
                SUM(
                    `assessment`.`percentage_achieved` *(
                        `assessment`.`percentage_weighting` / 100
                    ) /(
                    SELECT
                        COUNT(*)
                    FROM
                        `module`
                    WHERE
                        `yearGroup`.`id` = `module`.`year_group_id`
                )
                ),
                0
            ) / 100 * `yearGroup`.`max_credits`,
            2
        ) AS `credit_achieved`
    FROM
        `assessment`
    RIGHT JOIN `module` ON `module`.`id` = `assessment`.`module_id`
    RIGHT JOIN `yearGroup` ON `yearGroup`.`id` = `module`.`year_group_id`
    RIGHT JOIN `course` ON `course`.`id` = `yearGroup`.`course_id`
    RIGHT JOIN `yearGroupLookup` ON `yearGroup`.`yearLookup_id` = `yearGroupLookup`.`id`
    WHERE
        `yearGroup`.`course_id` = 1
    GROUP BY
        `yearGroup`.`id`
Minor stuff: your backticks are distracting, and unnecessary in most (all?) cases. I'd delete them.
Your use of TRUNCATE seems like a formatting concern and not a query concern. I'd expect that a query like this just return a full, floating-point number, and leave it up to the application as to whether rounding or truncation needs to be performed.