1
I’m having a little problem with the consultation to generate a report. I made a JOIN of the orders table (that will take the report) with the table of customers and products. Until then everything worked, but it hardly shows all the requests, only shows the first. At the moment I have about 3 requests related to the tables. See the code:
SELECT pedidos_id,
pedidos.cliente_id,
pedidos.produto_id,
clientes.nome AS nome_cliente,
produtos.nome AS nome_produto,
pedidos.data,
pedidos.frete,
pedidos.quantidade,
pedidos.total,
SUM(pedidos.total) as sub_total
FROM pedidos
INNER JOIN clientes ON pedidos.cliente_id = clientes.clientes_id
INNER JOIN produtos ON pedidos.produto_id = produtos.produtos_id
ORDER BY clientes.nome
Missed the
GROUP BY pedidos_id
, nay?– Sorack
Dude it even works but the problem is the sub-total. It does not sum the values of the total at all.
– Felipe Michael da Fonseca
You need to be a little clearer on your question. What data do you expect at the end? How do you intend to get the subtotal?
– Sorack
The sub-total has to be from the total column. See I have 3 records and I need him to make the relationship with the other two tables of customers and products and each order has a total. The sub-total would be the sum of all requests in the total column.
– Felipe Michael da Fonseca
Dude.... if you want to make a report, the total is summed up in the report itself and not in select... what are you using to make the report ?
– Rovann Linhalis