0
I’m starting to study the SQL language and the interaction between the tables, and I came across an exercise in a list that I’m not able to solve.
He asks the following:
For each existing product say what sales were made and how many items were ordered.
I tried this solution, but I did not reach the expected answer:
SELECT
p.nome, COUNT(i.fk_venda)AS qtd_venda
FROM
tb_produto AS p, tb_itens AS i
WHERE
p.pk_produto=i.fk_produto
GROUP BY
p.nome;
Your script prints which result ?
– Tulio Calil
@Tuliocalil groups all registered items, with the exception of one of them. And the sum of the quantities sold does not match what I recorded earlier.
– Lucas Dirani
You can export the bank so I understand better here ?
– Tulio Calil
@Tuliocalil the Caique has solved my doubt, but I still thank you for your attention!
– Lucas Dirani
You’re welcome! Good luck and success!
– Tulio Calil