Fetch Products Grouped By Total Sales ?
Posted
by David
on Stack Overflow
See other posts from Stack Overflow
or by David
Published on 2010-06-14T18:26:40Z
Indexed on
2010/06/14
18:32 UTC
Read the original article
Hit count: 163
Hi, I have the following MySQL tables:
TABLE: Products
----------------------
id | productname
1030 | xBox 360
1031 | PlayStation 3
1032 | iPod Touche
TABLE: Sales
----------------------
productid | saledate
1031 | 2010-06-14 06:30:12
1031 | 2010-06-14 08:54:38
1030 | 2010-06-14 08:58:10
1032 | 2010-06-14 10:12:47
I want to fetch using php the products i sold today and groupe them by sales number and order by sale date (if possible) , example of Output:
Today's statistics:
-Playstation 3 (2 sales)
-Xbox 360 (1 sale)
-iPod Touche (1 sale)
Thanks
© Stack Overflow or respective owner