
WITH leaves AS (
    SELECT a.id, a.name
    FROM assets a
    WHERE NOT EXISTS (SELECT 1 FROM assets c WHERE c.parent_id = a.id)
)
SELECT l.id, l.name
FROM leaves l
LEFT JOIN events e ON e.asset_id = l.id
WHERE e.asset_id IS NULL
ORDER BY l.name;