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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T15:32:16+00:00 2026-05-11T15:32:16+00:00

I have a table: Id Catg 1 cat01 2 cat01 3 cat01 1 cat02

  • 0

I have a table:

Id  Catg 1   cat01 2   cat01 3   cat01 1   cat02 2   cat02 

now I want to detect number of occurance of catg01 and catg02,like in this ex, catg01 is 3 times and catg02 is 2 times,I want to count that through LINQ/ simple db query. Pls note: cant use Where clause and hardcode Catg01/catg 02,as there can n number of category.Is it possible to detect? if yes then pls help.

  • 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. 2026-05-11T15:32:17+00:00Added an answer on May 11, 2026 at 3:32 pm
    Select Catg, Count(*) From TableName Group By CatG 

    For the LINQ Version. Imagine a Class

        class Table     {         public int ID { get; set; }         public string CatG { get; set; }     }  

    Then if you had a list of that class, you could query it as follows

    List<Table> y = new List<Table>();  y.Add(new Table() { ID = 1, CatG = 'a' }); y.Add(new Table() { ID = 2, CatG = 'a' }); y.Add(new Table() { ID = 3, CatG = 'a' }); y.Add(new Table() { ID = 4, CatG = 'b' }); y.Add(new Table() { ID = 5, CatG = 'b' });   var query = y.GroupBy(table => table.CatG);  // Iterate over each IGrouping in the collection. foreach (var item in query) {     Console.WriteLine('CatG: {0} Number of Items: {1}', item.Key, item.Count()); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table called Direccion other called Cliente each one defined like this public
I have table field defined as like this approved_at DATETIME YEAR TO SECOND NOT
I have table in an MS Access database that looks like this: ID Symbol
I have table structure like this: ID cond 1 5 1 2 1 6
I have table like this create table tbl_1( year int, month int, day int
I have table (call it my_table ) that can be simplified like this: NAME,
I have table like this: +------+-------+ | user | data | +------+-------+ | 1
i have table structure with 3 colums (column1, column2, column3) and i want to
I have table with 3 columns A B C. I want to select *
I have table in data base name train delay, with columns train number(int), DelayTime(int),

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.