0
I would like to average the amounts spent by all customers. Then list the names of customers who spent above average (can be using inner join, but with sub-consultation):
SELECT a.primeiro_nome, AVG(b.valor) AS media
    FROM cliente AS a
    INNER JOIN pagamento AS b ON (a.cliente_id = b.cliente_id)
    GROUP BY a.cliente_id
      HAVING media > (SELECT 
        AVG(valor)
         FROM pagamento);
Welcome Felipe, try to bring as much detail into your question by showing how far your current code and table structure are.
– André Lins
Felipe Good night! if you can drill in better with codes becomes easier to help you.
– Jandelson Oliveira
Your query presented some problem?
– anonimo
I needed something more specific
– Felipe