I need to build one table that show all the sales for one day that i’ve choosen.
I’ve allways used the dummy way, selecting the table products that had a sale in one day, then do a loop on a php table do get the other informations from others tables.
I wanna know if theres is a simple way getting the data.
TABLES:
table_products
pr_id | pr_name | pr_price | ..
------|---------|----------|
1 | TV | 299.99 |
2 | RADIO | 59.99 |
3 | DVD | 49.99 |
.. | .. | .. |
table_sales
sa_id | sa_coupon | sa_day | sa_month | ..
------|-----------|----------|----------|
1 | 101 | 4 | 9 |
2 | 102 | 5 | 9 |
3 | 103 | 5 | 9 |
.. | .. | .. |.. |
80 | 211 | 2 | 12 |
.. | .. | .. |.. |
table_sales_dt
sa_dt_coupon | sa_dt_product_id | sa_qtd |
-------------|------------------------|-------------|..
101 | 1 | 10 |
101 | 2 | 5 |
102 | 1 | 5 |
103 | 3 | 8 |
211 | 1 | 15 |
211 | 2 | 10 |
211 | 3 | 5 |
.. | .. | .. |
i want to show the results like this:
Sales on month 9 (september)
N PRODUCT QUANTITY PRICE TOTAL
1 - TV - 15 - 299.99 - 4499.85
2 - RADIO - 5 - 59.99 - 299.95
3 - DVD - 8 - 49.99 - 399.92
THANKS!!!
Something like this might do it: