Skip to content
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: invalid SQL generated for groupby aggregate query projecting key sum of group key with itself #12656

Closed
maumar opened this issue Jul 12, 2018 · 1 comment

Comments

@maumar
Copy link
Contributor

maumar commented Jul 12, 2018

query:

var query = (from o in ctx.Orders
                             join c in ctx.Customers
                                 on o.CustomerID equals c.CustomerID into grouping
                             from c in grouping.DefaultIfEmpty()
                             select o)
                        .GroupBy(o => o.OrderID)
                        .Select(
                            g => new
                            {
                                Value = g.Key + g.Key,
                                Average = g.Average(o => o.OrderID)
                            });

                var result = query.ToList();

sql:

SELECT [o].[OrderID] AS [Key] + [o].[OrderID] AS [Key] AS [Value], AVG(CAST([o].[OrderID] AS float)) AS [Average]
FROM [Orders] AS [o]
LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID]
GROUP BY [o].[OrderID]

Exception:

Incorrect syntax near '+'.

@smitpatel
Copy link
Member

Duplicate of #12826

@smitpatel smitpatel marked this as a duplicate of #12826 Jul 27, 2018
@smitpatel smitpatel removed this from the 2.2.0 milestone Jul 27, 2018
@smitpatel smitpatel removed their assignment Jul 27, 2018
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants