Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. SELECT d.name,
  2. IF( AVG(DATEDIFF(r.close_date, r.open_date)), FLOOR(AVG(DATEDIFF(r.close_date, r.open_date))), 'no info') AS `average_duration`
  3. FROM departments AS d
  4. JOIN categories AS c ON c.department_id = d.id
  5. JOIN reports AS r ON r.category_id = c.id
  6. GROUP BY d.name
  7. ORDER BY d.name;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement