SELECT
  a.id AS account_id,
  a.display_name,
  COUNT(t.id) AS ticket_count,
  SUM(CASE WHEN t.status = 'open' THEN 1 ELSE 0 END) AS open_ticket_count
FROM accounts a
LEFT JOIN tickets t ON t.account_id = a.id
GROUP BY a.id, a.display_name
ORDER BY a.id;
