In my database i have the following schema:
table: files
columns: fileId, authorId, fileSize
table: authors
columns: authorId, surname, firstName
Now id like to select the authorId of the author which has the highest average of fileSize. I am a bit clueless right now on how i best join these tables. I have already been able to select the average fileSize for an author, but now must extend that to work with each author.
SELECT AVG(`fileSize`) FROM (
SELECT `fileSize`, `files`.`authorId` FROM `files`
INNER JOIN `authors` aut ON `files`.authorId = aut.authorId
WHERE aut.authorId = 6)
as T;