Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT d.name,
- IF( AVG(DATEDIFF(r.close_date, r.open_date)), FLOOR(AVG(DATEDIFF(r.close_date, r.open_date))), 'no info') AS `average_duration`
- FROM departments AS d
- JOIN categories AS c ON c.department_id = d.id
- JOIN reports AS r ON r.category_id = c.id
- GROUP BY d.name
- ORDER BY d.name;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement