title: Arithmetic's in an update statement in sql
body: <p>I really can't wrap my head around this update sql statement.</p>
  
  <p>I have the following schema for a copy table and a rental table :</p>
  
  <p><strong>copy</strong> (
    copy_id ,
    movie_id ,
    branch_id ,
    primary key (copy_id));</p>
  
  <p><strong>rental</strong> (
    customer_id,
    copy_id  ,
    outdate ,
    returndate ,
    primary key (customer_id,copy_id,outdate));</p>
  
  <p>There will be multiple copies of the same movie. for a single movie_id, we can have multiple copy_id.
  Each copy of a movie has a globally unique copy_id. So copies of 2 different movies cannot have the same copy_id.</p>
  
  <p>There are multiple branches that have a copy of the movie, and certainly the copy_id will be unique.</p>
  
  <p>The same movie and copy will definitely appear in rented multiple times, if it has been rented more than once.</p>
  
  <p>I need to write a update statement such that - say we have 10 copies of a movie at a branch, and a time span of 30 days, so out of 300 rental days(30 days * 10 copies) the copies need to be rented out for at least 290 rental days. If this is true then I need to add another copy of that particular movie at that branch.</p>
  
  <p>I tried to explain the problem in the best possible way I could. In short, I need to add a copy if the movie is rented out 90% of the time at a branch.</p>