I’m trying to build this query as my controllers index action.
select * from users join (select user_id, sum(end_date - start_date) as scheduled_hours from schedules group by user_id) as hours on users.id = hours.user_id
But nothing I do with the query builder seems to want to work. This is an attempt to add a sum to my entities (the sum of end_date - start_date) in the Schedules table for each user in my user’s table.
I’m trying to do this in the controller, but should I be doing it in the Entity class or Table?