Displaying 1 result from an estimated 1 matches for "total_client_minut".
Did you mean:
total_client_minutes
2006 Jul 16
4
Calculations across multiple tables
...e
a grouped result?
The SQL I''m feeding to find_by_sql comes out something like this:
SELECT client_id, task_id, project_id, clients.client_name,
tasks.description,
time_records.start_at,
(SUM(TIME_TO_SEC(time_records.end_at) -
time_to_sec(time_records.start_at)) / 60) AS total_client_minutes,
(SUM(TIME_TO_SEC(time_records.end_at) -
time_to_sec(time_records.start_at)) / 3600) AS total_client_hours
FROM clients, tasks, time_records
WHERE tasks.client_id = clients.id AND time_records.task_id = tasks.id
GROUP BY client_id, project_id, task_id WITH ROLLUP;
--
View t...