title: Getting all possible combinations which obey certain condition with MS SQL
body: <p>I need to constract an SQL query but I have no idea how to do it. If someone helps, I'll appriciate it very much.</p>
  
  <p>I have the following table</p>
  
  <pre><code>GroupedBYField          ConditionField          ToBeSummeField
       1                        1                      1
       1                        1                      2
       1                        1                      3
       2                        2                     100
       2                        2                     200
       2                        2                     300
  </code></pre>
  
  <p>and I need to get all the possible combinations of <code>groupedBYField, SUM(ToBeSummeField)</code> which has
  <code>SUM(conditionField) = 2</code>, that is the following table</p>
  
  <pre><code>GroupedBYField          SumField
       1                     3
       1                     4
       1                     5
       2                    100
       2                    200
       2                    300
  </code></pre>
  
  <p>Thank you for your help!</p>