Using an SQL procedure might result in incorrect results when all of the following conditions occur:
- The query references a previously created view in the FROM clause.
- The previously created view contains an aggregate function in the SELECT clause, and that function has been given an alias.
- That alias appears in the SELECT clause of the current query, but it does not appear in the GROUP BY clause.
The only workaround is to create a table rather than a view in the previous query and use that table in the FROM clause.