Count product output on day in mysql

Asked

Viewed 57 times

1

I have an exit table of stock materials which is organized as follows

inserir a descrição da imagem aqui

I have products in stock every time I leave is released the number indicating the product id, the amount of output and the day, throughout the day there can be several records of outputs of the same product.

I need to take the output values of a given product on a given day and add to know how many products came out on the specified day, I’m trying to following the query

SELECT COUNT(qtd_saida) as total FROM tbl_limpeza_saida_diaria WHERE produto_id=7 AND data_uso=DATE(NOW())

But this way up brings me the amount of records and not the sum of product outputs.

How do I add the amount of output of a given product on a given day?

2 answers

1


As Dbalone said:

SELECT produto_id, data_uso, SUM(qtd_saida) as total FROM tbl_limpeza_saida_diaria 
WHERE produto_id=7 AND data_uso=DATE(NOW())
GROUP BY produto_id, data_uso;

-2

Try with a groupBy by date, forcing the ID of the product and joining them by date and adding to Qtde

Browser other questions tagged

You are not signed in. Login or sign up in order to post.