title: Group by with Named Parameter with Spring's NamedParamterJdbcTemplate
body: <p>I'm using PostgreSQL and Spring 3.1 NamedParameterJdbcTemplate.</p>
  
  <p>If I have some SQL which uses a named parameter in the Select &amp; Group By clauses, Postgres will return this as bad grammar. Running the query with the parameters manually replaced will work correctly.</p>
  
  <p>Assume there is a table called 'table' with 2 columns "id" and "number"</p>
  
  <p>This SQL:</p>
  
  <p><code>SELECT some_function(id, :param), avg(number) FROM table GROUP BY some_function(id, :param)</code></p>
  
  <p>Becomes (as logged by the DB):</p>
  
  <p><code>SELECT some_function(id, $1), avg(number) FROM table GROUP BY some_function(id, $2)</code></p>
  
  <p>I suspect that the query planner looks at this query and it doesn't know that $1==$2, so it gives the error "column 'id' must appear in the GROUP BY clause or be used in an aggregate function."</p>
  
  <p>Is there are way to get around this using Spring? Is there some way to get it so the query becomes:</p>
  
  <p><code>SELECT some_function(id, $1), avg(number) FROM table GROUP BY some_function(id, $1)</code> instead? The query planner would be okay with this I suspect.</p>