Thread: query help
View Single Post
  #18 (permalink)  
Old 08-08-10, 07:37
sakitram sakitram is offline
Registered User
 
Join Date: Aug 2010
Posts: 13
Quote:
Originally Posted by r937 View Post
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 View Post
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 View Post
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
Reply With Quote