I have a data source that can return results using a different set of GROUP BY fields based on the user's choice from a dropdown. I'm using a Velocity expressions to customize the SQL SELECT clause. Fields that aren't to be included in the GROUP BY list I wrap in a SQL aggregate function like SUM or MIN. That all works fine.
The user can also create criteria using a FilterBuilder. That's where the problem comes in. If a field referenced in the criteria has been wrapped in an aggregate function I need to move it from the WHERE clause to a HAVING clause and use the aggregate function instead of the simple field name.
Do you have any suggestions on how to do that? Are there any utility methods in SQLDataSource that might help me accomplish this?
The user can also create criteria using a FilterBuilder. That's where the problem comes in. If a field referenced in the criteria has been wrapped in an aggregate function I need to move it from the WHERE clause to a HAVING clause and use the aggregate function instead of the simple field name.
Do you have any suggestions on how to do that? Are there any utility methods in SQLDataSource that might help me accomplish this?
Comment