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 6107953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:14:40+00:00 2026-05-23T14:14:40+00:00

Hi i am having difficulties to group these data as it has no aggregate

  • 0

Hi i am having difficulties to group these data as it has no aggregate function. I have the following data in 2 tables and i would like to Join both by PaymentId and display only 1 row of record.

enter image description here

Question:
How do i display the final result in only 1 ROW groupby CoursePaidForMonthYear.
I would like to get all data from Payment.*, TutorCourseCommissions.* and CoursePaidForMonthYear column in same row displaying (September, October, November)

Example:

referenceId| TutorId| CoursePaidForMonthYear                 |  
1          | 1019   | September, October, November OR 9,10,11|

My work:

 var result = from u in db.Users
                    join p in db.Payments on u.Id equals p.UserId
                    join tt in db.TutorCourseCommissions on p.Id equals tt.PaymentId into gtt
                        from tt in gtt.DefaultIfEmpty()                       
                    where u.Id == user.Id
                    GroupBy tt.CoursePaidForMonthYear  ??
                    select new { u, p, tt };

            foreach (var r in result)
            {
                Payment payment = new Payment();                  
                payment.MonthToPay = (r.tt == null) ? null : common.GetMonthName(r.tt.CoursePaidForMonthYear.Month, true);
                payment.Amount = r.p.Amount;                    

                output.Add(payment);
            }
            return output;
  • 1 1 Answer
  • 0 Views
  • 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-23T14:14:41+00:00Added an answer on May 23, 2026 at 2:14 pm

    What you need to do is group the months by the user and payment, and then perform an aggregation on the grouped months. In this case I used String.Join() to combine the distinct months coming from the commission.

    This will give you results along the lines of { User = "John Doe", Payment = ..., Months = "January, February" }

    var result = from u in db.Users
                  where u.UserID == user.Id
                  join p in db.Payments on u.Id equals p.UserId
                  join comm in db.TutorCourseCommissions 
                  on p.Id equals comm.PaymentId
                  group common.GetMonthName(comm.CoursePaidForMonthYear,true)
                  by new { User = u, Payment = p } into g
                  select new 
                  {
                     User = g.Key.User,
                     Payment = g.Key.Payment,
                     //...select out other properties here... 
                     Months = String.Join(", ", g.Distinct())
                  };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to get the following query to function but I'm having difficulties with
I am having difficulties how to construct my question, but if I have to
I'm having difficulties displaying data in a UITextView in iPhone programming. I'm analyzing incoming
I'm having difficulties adding momentum to my spinning wheel. I have this wheel (something
I'm having difficulties working with some legacy enums that have multiple zero values. Whenever
I'm having difficulties reading an app.config using the ConfigurationManager. I have a custom section,
I'm having difficulties seeing why one way works and way doesn't. I have; switch
I am having difficulties getting the following to export. I am running CR2008SP2 and
i'm having difficulties implementing custom widget rendering in a QListView . I currently have
I am developing a Swing/Java app but having difficulties passing data from the initiliaser

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.