I did it slightly different, without using aggregate functions. Thank you for the provided solution.