Forum Moderators: open

Message Too Old, No Replies

store daily total in the same mysql query

find sum of daily values

         

phparion

9:06 am on Jul 22, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



hi,

I have a MySQL query that pulls off a report from database.

SELECT DATE_FORMAT(s.date,'%d-%m-%Y') as date, s.customer, s.biller, si.product_name, FLOOR(si.quantity) as quantity, FLOOR(si.unit_price) as unit_price
FROM sale_items si, sales s
WHERE s.warehouse_id = si.warehouse_id
AND s.id = si.sale_id
AND ".$ssucursal."
AND si.product_code = '".$sku."'
AND s.date >= '".$iniDate."' AND s.date <= '".$endDate."'
ORDER BY s.date DESC


I get a date-wise report from this for example if a given product is sold ten times in a single day it will show ten records and quantity of each sale.
I want to get a daily total of the daily sales as well, so I know what is the total quantity sold in ten sales in that given day.

I am caught off the guard, please guide :)

thank you

csdude55

6:00 pm on Aug 11, 2021 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I'm not entirely sure that I understand the question, and after 2-3 weeks I'm not even sure if you still need it. But I think you're looking for a second query that would show the sum for FLOOR(si.quantity):

SELECT SUM(FLOOR(si.quantity))
FROM sale_items si, sales s
WHERE s.warehouse_id = si.warehouse_id
AND s.id = si.sale_id
AND ".$ssucursal."
AND si.product_code = '".$sku."'
AND s.date >= '".$iniDate."' AND s.date <= '".$endDate."'