0

Question: Show which people are alive, their ages to people above the average age of living people.

SELECT nome, TIMESTAMPDIFF (YEAR, data_nasc,CURDATE()) AS "Idade"
FROM pessoas
WHERE data_morte IS NULL AND TIMESTAMPDIFF (YEAR, data_nasc,CURDATE()) > AVG(TIMESTAMPDIFF (YEAR, data_nasc,CURDATE()));

When I put it in Mysql, this error appears, I've tried in several ways and I couldn't solve it, can you help me please? ERROR 1111 (HY000): Invalid use of group function

Bruno
  • 1
  • 5

0 Answers0