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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:14:19+00:00 2026-05-27T03:14:19+00:00

I have a table with a primary key and row key column. The data

  • 0

I have a table with a primary key and row key column. The data looks like below. The data has already been loaded into a table that is a collection.

Primary Key    Row Key
01000100001  000001 - Subject ID=1, Book ID=1, Chapter ID=1 and Page ID=1
01000100001  000002 - Subject ID=1, Book ID=1, Chapter ID=1 and Page ID=2
01000100001  000003 - Subject ID=1, Book ID=1, Chapter ID=1 and Page ID=3
01000100002  000004 - Subject ID=1, Book ID=1, Chapter ID=2 and Page ID=4
01000100002  000005 - Subject ID=1, Book ID=1, Chapter ID=2 and Page ID=5
01000100002  000006 - Subject ID=1, Book ID=1, Chapter ID=2 and Page ID=6
01000200003  000007 - Subject ID=1, Book ID=2, Chapter ID=3 and Page ID=7
01000200003  000008 - Subject ID=1, Book ID=2, Chapter ID=3 and Page ID=8
02000300004  000009 - Subject ID=2, Book ID=3, Chapter ID=4 and Page ID=9
02000300005  000010 - Subject ID=2, Book ID=3, Chapter ID=5 and Page ID=10

The collection class is called Pages and contains a column called PrimaryKey which is made up of the following:

2 column Subject ID
4 column Book ID
4 column Chapter ID

I need to create a report that looks something like the following and I am wondering
if and how I could create a query for this with LINQ.

Subject  Books  Chapters      Pages

01         2         3           8
02         1         2           2

Any suggestions on how I could do this would be much appreciated.

  • 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-27T03:14:20+00:00Added an answer on May 27, 2026 at 3:14 am

    You can use the group by and sum features the linq query would look something like this:

    from page in pages
    group page by new { 
                        page.subjectId
                        , page.bookId
                        , page.chapterId 
                     } into group
    select new {
                 group.key.SubjectId
                 , group.key.bookId
                 , group.Key.chapterId
                 , total = pages.sum(s => s.Page)
    }
    

    Sorry that I don’t have visual studio available right now, but this should give you a pretty good start.

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

Sidebar

Related Questions

I have table A in Oracle that has a primary key (id). I need
I have a table with a clustered primary key index on a uniqueidentifier column.
I have a table that has a primary key that's an INT... I have
I have an Oracle table with data that looks like this: ID BATCH STATUS
I have two data tables which have a primary key column in common but
Assuming I have a table SomeTable with the following data: Primary Key Column1 Column2
In an existing application, I have a table which has no primary key, which
I have a table with primary key in my MS SQL Server 2005 table.
I have a table whose primary key is used in several other tables and
I have a table with primary key (ColumnA, ColumnB). I want to make a

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.