title: T-SQL Dynamic GROUP BY using @parameters
body: <p>I would like to achieve</p>
  
  <pre><code>SELECT @param1, @param2, @param3, t.field1, sum(t.amount)
  FROM table t
  WHERE t.field 2 IS NOT NULL AND
  t.field3ID = '12345'
  GROUP BY @param1, @param2, @param3
  </code></pre>
  
  <p>What is the best approach? Is building dynamic SQL is the way to go? </p>