Опитайте това:
На един ред:
SELECT SUM(Class.Students * Books.Cost) AS BookCost FROM Books INNER JOIN Class ON Books.ClassId = Class.ClassId WHERE Books.ClassId = <CLASS-ID-VALUE> GROUP BY Books.ClassId
С форматиране:
SELECT SUM(Class.Students * Books.Cost) AS BookCost
FROM Books INNER JOIN Class
ON Books.ClassId = Class.ClassId
WHERE Books.ClassId = <CLASS-ID-VALUE>
GROUP BY Books.ClassId