The answer may be obvious for experienced MySQL coders but I have hit the wall trying to figure this out.
I need to get a list of stores ranked by the total sales last month of each location.
My sales are in three tables with similar structures but the three tables have diferent names and fields
Table 1 is called empsalesa and its fields are:
emp_no_a, sales_date_a, months_sales_a
Table 2 is called empsaless and its fields are:
emp_no_s, sales_date_s, months_sales_s
Table 3 is called empsalesw and its fields are
emp_no_w, sales_date_w, months_sales_w
The store numbers are in a separate table called empinfo
employee_number , store_number
(There is other data in the empinfo file but it is irrelevent to this calculation.)
I need to get the store numbers ranked by total store sales for the month (the sum of the three tables) in decending order. I don't need the sales, just the ranking since this list then feeds other processes.
The dates are in standard 0000-00-00 format. The employee numbers can be alphanumeric. The dates in the sales file are always the last day of the month in which the sales occurred. The date for the month that I want to rank is available as a variable - $dt
I would appreciate any ideas.
Thanks
Brian