Monday, 15 April 2013

php - SUM in MySQL with ORDER BY and LIMIT -



php - SUM in MySQL with ORDER BY and LIMIT -

suppose have next mysql table:

i know total volume fuji apples 3 days before latest sale date (like moving total). example, after total volume selection 3 days prior 04/01/14, 9.

i have made number of attempts without intended results:

select sum(volume) (select `volume` `fruit_sale_db` `fruit` = 'apple' , `type` = 'fuji') subquery order `date` desc limit 1,3

i thought order date desc limit 1,3 work restricting dates 3 starting sec lastly entry doesn't work.

select sum(volume) `fruit_sale_db` 'date' >= (latest_sale_date - 3) , 'date' <= latest_sale_date , `fruit` = 'apple' , `type` = 'fuji'

and latest_sale_date like

select `date` `fruit_sale_db` `fruit` = 'apple' , `type` = 'fuji' order `date` desc limit 1

php mysql sql

No comments:

Post a Comment