Question : SQL view filtering using fields not in GROUP BY clause

Hello,
I'm trying to build a simple summary report using grouping and a COUNT column. I don't want the details to be available, just the summary information, so I want to use a SQL view that performs the grouping functions and just base my report on that view.

The problem is that in this case, we need to filter the results using a date field in the underlying table. I can't hard code the dates into the WHERE clause, as they need to be variable. But I can't put them in the select list and GROUP BY list, as they are not part of the grouping that I want and will mess up my COUNT field.

Is there any way that I can include a date field in my SQL view without it messing up my grouping and totals? Is there any other solution to this problem?

Thanks in advance for any help with this.

Answer : SQL view filtering using fields not in GROUP BY clause

I don't think that will be possible - from the outside of the view, you can only see the resultant fields (after group by) and have no access to underlying makeup of the view.

On adding a date column to the view - if each row is a summary of say 10 rows, which date would it be - see?

I would create a function/proc with the same body as the view but that can take a parameter into the WHERE clause.
Random Solutions  
 
programming4us programming4us