Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1004965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:12:58+00:00 2026-05-16T08:12:58+00:00

help me please with this simple E-sql query: var qStr = SELECT SqlServer.Month(o.DatePaid) as

  • 0

help me please with this simple E-sql query:

var qStr = "SELECT SqlServer.Month(o.DatePaid) as month, SqlServer.Sum(o.PaidMoney) as PaidMoney FROM XACCModel.OrdersIncomes as o group by SqlServer.Month(o.DatePaid)";

Here’s what I have.

I have simple Entity called OrdersIncomes with ID,PaidMoney,DatePaid,Order_ID properties

I want to select Month and Summed PaidMoney like this:

month  Paidmoney

1 500

2 700

3 1200

T-SQL looks like this and works fine:

    select MONTH(o.DatePaid), SUM(o.PaidMoney)
    from OrdersIncomes as o
    group by MONTH(o.DatePaid)

results:
-----------

3           31.0000

4           127.0000

5           20.0000

(3 row(s) affected)

but E-SQL doesnot work and I dont know what to do. here my E-SQL which needs refactoring:

var qStr = "SELECT SqlServer.Month(o.DatePaid) as month, SqlServer.Sum(o.PaidMoney) as PaidMoney FROM XACCModel.OrdersIncomes as o group by SqlServer.Month(o.DatePaid)";

there’s an exception: ErrorDescription = “The identifier ‘o’ is not valid because it is not contained either in an aggregate function or in the GROUP BY clause.”

if I include o in group by clause, like: FROM XACCModel.OrdersIncomes as o group by o
then I don’t get summed and aggregated results.
Is this a bug, or what I’m doing wrong?

Here’s a Linq to Entities query and it works too:

var incomeResult = from ic in _context.OrdersIncomes
     group ic by ic.DatePaid.Month into gr
     select new { Month = gr.Key, PaidMoney = gr.Sum(i => i.PaidMoney) };
  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T08:12:59+00:00Added an answer on May 16, 2026 at 8:12 am

    Give an alias name to the Group By clause and use that alias in the select clause.

    SELECT PaidMonth, SqlServer.Sum(o.PaidMoney) as PaidMoney
    FROM XACCModel.OrdersIncomes as o
    group by SqlServer.Month(o.DatePaid) as PaidMonth

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a t-sql query written with this sample help . SELECT t.gName AS
Please help the SQL Query in LINQ form - C# .NET 3.5 select distinct
please help me to understand how the T-SQL's UPDATE FROM query works. the sample
This is a simple one! yet, I am missing something. Please help me out.
This may be very simple question,But please help me. i wanted to know what
may be too simple groovy question but....please help i have a list like this:
Please help with search string encoding. Simple request like this: https://graph.facebook.com/search?q=max&type=user works pretty good,
Please help this beginner here... I have a SQL Server 2008 R2 running on
Please help me with this update query. I COMPLETELY understand how redundant this is
I hope someone can help with this please. I am trying to query an

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.