Hello, I have a situation here.
Here are the 3 tables extracted from my database, (staff, resource_management, project)
-
staff (id, name)
-
resource_management (staff_id, project_id, date_transfer)
-
project (id, code, end_date)
Relation
1 and 2 (one to many)
2 and 3 (many to one)
Here is what I want my cgridview to look like
distinct(Staff.id) , staff.name, max(project.end_date), project.code, resource_management.date_transfer
This is what I have currently in my staff model.
'transfer'=>array(self::HAS_ONE,'ResourceManagement','staff_id','alias'=>'i','select'=>'*',
'join'=>'LEFT JOIN(select max(date_transfer) as max FROM resource_management GROUP BY staff_id) j ON i.date_transfer = j.max'),
'projects'=>array(self::HAS_ONE,'Project','project_id','through'=>'transfer'),
The above code is getting the max date_transfer but how do I get the max(end_date) for project ?