title: Compute from columns contain in 'with' clause
body: <p>I'm trying to find the number of late returned by film id as a % of total returns. </p>
  
  <p>I've tried creating columns using the with clause, however it will not allow the columns that I've created to be used in the select statement</p>
  
  <pre><code>;with totalrentals as
  (
  select totalrentals = count(*), f.film_id , f.title 
  from film f
  inner join inventory i on i.film_id = f.film_id 
  inner join rental r on r.inventory_id = i.[inventory_id]
  group by f.film_id , f.title)
  , laterentals as (
  select  i.film_id, f.title,r.return_date,duedate=    (r.rental_date+f.rental_duration)
  from rental r
  inner join inventory i on r.inventory_id = i.inventory_id 
  inner join film f on f.film_id = i.film_id 
  where r.return_date &gt; (r.rental_date+f.rental_duration)
  group by i.film_id,f.title,r.rental_date+f.rental_duration, r.return_date 
  ),
  lr as
  (
  select Laterentals = count(*), f.film_id , f.title 
  from laterentals
  inner join film f on laterentals.film_id = f.film_id 
  group by f.film_id, f.title 
  )
  select f.film_id, f.title, lr.laterentals ,tr.totalrentals ,pctlate =     (lr.Laterentals  /tr.totalrentals)*100
  from film f 
  inner join  lr on lr.film_id = f.film_id 
  inner join totalrentals tr on tr.film_id  = f.film_id
  inner join inventory i on i.film_id = f.film_id 
  inner join rental r on r.inventory_id = i.inventory_id 
  group by f.film_id , f.title, lr.laterentals , tr.totalrentals 
  order by f.film_id  asc
  </code></pre>
  
  <p>Expecting the report to output late returns as % of total returns</p>
  
  <p>Instead, all pctlate values = 0</p>
  
  <pre><code>Film_ID   Title               Laterentals     Totalrentals    pctlate
  1         ACADEMY DINOSAUR              7               23         0
  2         ACE GOLDFINGER                5                7         0
  </code></pre>