Rails 7.1 - construct Common Table Expression using .with query method

In Rails 7.1 .with query method makes it super easy to build and chain complex Common Table Expression CTE queries.