I was wondering if anyone would be able to review my Grade Calculator for a course ERD? I'm looking for ways to improve the current design (if any improvements need to be made that is) and if anyone could review the current MySQL query which is there. In order for this to be reviewed I was told I needed an SQL query to accompany it.
SELECT
`yearGroup`.`id` AS `year_group_id`,
`yearGroup`.`year` AS `year_group`,
CONCAT(
TRUNCATE
(
COALESCE(
SUM(
`assignment`.`percentage_achieved` *(
`assignment`.`percentage_weighting` / 100
)
),
0
) /(
SELECT
COUNT(*)
FROM
`unit`
WHERE
`unit`.`year_group_id` = `yearGroup`.`id`
),
2
),
'%'
) AS `grade`
FROM
`assignment`
RIGHT JOIN `unit` ON `unit`.`id` = `assignment`.`unit_id`
RIGHT JOIN `yearGroup` ON `yearGroup`.`id` = `unit`.`year_group_id`
WHERE
`yearGroup`.`course_id` = 1
GROUP BY
`yearGroup`.`id`