title: query to find diff between two records
body: <p>I have following tables</p>
  
  <pre><code>movies
    - id
  
  details
    - user_id 
    - movie_id 
    - rating
  
  users
    - id
  </code></pre>
  
  <p>detail belongs to user and movie</p>
  
  <p>I want to find the the diff between the rating of two users say id 3,10</p>
  
  <p>simply I want answer of this</p>
  
  <pre><code>sum(10-(user1.rating - user2.rating))
     where rating is &gt; 0 
  </code></pre>
  
  <p>i.e both users should have given at-least non zero rating</p>