-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Query: GroupBy with Where produces invalid SQL #10870
Comments
@smitpatel Of course, thats pretty much the SQL EF6 did generate (for MSSQL, but works for SQLite as well). SELECT
[GroupBy1].[K1] AS [Size]
FROM ( SELECT
[Extent1].[Size] AS [K1],
COUNT(1) AS [A1]
FROM [dbo].[FileEntries] AS [Extent1]
GROUP BY [Extent1].[Size]
) AS [GroupBy1]
WHERE [GroupBy1].[A1] > 1 |
It seems like almost all relational providers have Having clause supported in SelectExpression. We will try to translate to Having clause instead of causing a subquery (like EF6). |
- Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870 - Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157 - GroupBy Aggregate works when key/element/result selector is DTO instead of anonymous type Resolves #11176 - Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218 Part of #10012
- Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870 - Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157 - GroupBy Aggregate works when key/element/result selector is DTO instead of anonymous type Resolves #11176 - Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218 - Translate GroupBy Constant/Parameter with aggregates Resolves #9969 Part of #10012
- Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870 - Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157 - GroupBy Aggregate works when element/result selector is DTO instead of anonymous type Resolves #11176 (KeySelector has to be client evaluated) - Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218 - Translate GroupBy Constant/Parameter with aggregates Resolves #9969 Part of #10012 Part of #2341
- Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870 - Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157 - GroupBy Aggregate works when element/result selector is DTO instead of anonymous type Resolves #11176 (KeySelector has to be client evaluated) - Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218 - Translate GroupBy Constant/Parameter with aggregates Resolves #9969 Part of #10012 Part of #2341
- Add support for translating OrderBy after GroupBy operator - Add support for `HAVING` clause in SQL which would be generated when translating predicate after GroupByAggregate Resolves #10870 - Make sure client eval warning is not issued when translating GroupByAggregate Resolves #11157 - GroupBy Aggregate works when element/result selector is DTO instead of anonymous type Resolves #11176 (KeySelector has to be client evaluated) - Make sure that SQL added to GROUP BY clause is not aliased Resolves #11218 - Translate GroupBy Constant/Parameter with aggregates Resolves #9969 Part of #10012 Part of #2341
We generate SQL like this now SELECT [o].[CustomerID] AS [Key], COUNT(*) AS [Count]
FROM [Orders] AS [o]
GROUP BY [o].[CustomerID]
HAVING COUNT(*) > 4" |
Unless I'm mistaken, |
Using GroupBy with Where produces invalid SQL
Steps to reproduce
Produced SQL
Expected SQL
Further technical details
EF Core version: 2.1.0-preview1-28226
Database Provider: Microsoft.EntityFrameworkCore.Sqlite
Operating system: Windows 10 Pro
IDE: Visual Studio 2017 15.6 p3
The text was updated successfully, but these errors were encountered: