Quote:
Originally Posted by r937
wtf is the "tmp" table? where did the emp_monthly_sales table go?
|
tmp is used instead of emp_monthly_sale as the table name is big.
Quote:
Originally Posted by r937
why are you joining the table to itself?
|
I join two tables one used as a primary key table and another used as a foreign key table to fetch max date of sales.
Quote:
Originally Posted by r937
please just give me the query to get each employee's latest date from the emp_monthly_sales table, so that i can show you how to build the final query that you're looking for
|
SELECT a.emp_id, max(b.dt) sales_date
FROM emp_monthly_sales a left join emp_monthly_sales b
on a.emp_id=b.emp_id
GROUP BY a.emp_id
Thanks