title: Sql server staged operation in query
body: <p>i have a table like this </p>
  
  <pre><code>id | userId | point | type
  1     3        3       1
  2     3        5       1 
  3     3        6       1
  4     3        2       2
  5     4        5       1
  </code></pre>
  
  <p>What i want to get is</p>
  
  <pre><code>userId | totalPoint
    3         28
    4         5
  </code></pre>
  
  <p>The way i calculate is to sum all points where type is 1 and multiply total of this sum by point where type is 2</p>
  
  <p>Example : (3+5+6)*2 = 28</p>
  
  <p>I tried many queries but i couldnt get it</p>
  
  <p>Any help is appreciated</p>