I'm trying to get all the wins per team, however, SQL decides to throw an error

The following query is being executed:
SELECT `t`.`teamcode`, COUNT(*) AS `gewonnen` FROM `Team` `t` INNER JOIN `Wedstrijd` `w` ON `w`.`teamthuis` = `t`.`teamcode` GROUP BY `w`.`teamthuis` HAVING `w`.`scorethuis` > `w`.`scoreuit` #1054 - Unknown column 'w.scorethuis' in 'having clause' Without aliases:
SELECT `Team`.`teamcode`, COUNT(*) AS `gewonnen` FROM `Team` INNER JOIN `Wedstrijd` ON `Wedstrijd`.`teamthuis` = `Team`.`teamcode` GROUP BY `Wedstrijd`.`teamthuis` HAVING `Wedstrijd`.`scorethuis` > `Wedstrijd`.`scoreuit` #1054 - Unknown column 'Wedstrijd.scorethuis' in 'having clause'
Wedstrijdhas a column with the namescorethuis?havingclause does not do what you think it does, is the columnscorethuisorscorehuis?