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

The Archive Base Latest Questions

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

I have a Tickets table with somewhat following structure (removed unnecessary columns) int |

  • 0

I have a “Tickets” table with somewhat following structure (removed unnecessary columns)

int | string   | int   |
ID  | Window   | Count |
------------------------
0   | Internet | 10    |
1   | Phone    | 20    |
2   | Fax      | 15    |
3   | Fax      | 10    |
4   | Internet | 5     |
.   | .        | .     |
.   | .        | .     |

And I have mapped this table to a class “Ticket”. So I can get all records like this:

var tickets = from t in db.Tickets
              select t;

Now I need to get the list of unique window names in the table. For above table, list would look something like:

  • Internet
  • Phone
  • Fax

Is there anyway to create this list without fetching all records and iterating over them?

I am using SQL Server 2008 express edition.

EDIT:
Thanks for the answers guys it solved the above problem. Just being greedy but is there any way to also get the total of count for each window. For example:

  • Internet = 15
  • Phone = 25
  • Fax = 20
  • 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-11T19:16:10+00:00Added an answer on May 11, 2026 at 7:16 pm

    How about:

    var tickets = db.Tickets.Select(t => t.Window).Distinct();
    

    I prefer to only use query expressions when I’m doing more than one operation, but if you like them the equivalent is:

    var tickets = (from t in db.Tickets
                   select t.Window).Distinct(); 
    

    To get the counts, you need to group:

    var tickets = from t in db.Tickets
                  group t by t.Window into grouped
                  select new { Window=grouped.Key, 
                               Total=grouped.Sum(x => x.Count) };
    
    foreach (var entry in tickets)
    {
        Console.WriteLine("{0}: {1}", entry.Window, entry.Total);
    }
    

    Note that this should all end up being performed at the database side – examine the SQL query to check this.

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

Sidebar

Related Questions

I have a table 'tickets' with the following columns id - primary key -
I have the following table: DECLARE @TicketHolder TABLE ( [Name] VARCHAR(100), Tickets DECIMAL(18, 8)
In my application, a user has_many tickets. Unfortunately, the tickets table does not have
I have two tables with the following columns: table1: id, agent_name, ticket_id, category, date_logged
I have an HTML table of tickets listings (e.g. http://seatgeek.com/event/show/23634/buffalo-bills-vs-tennessee-titans/ ). I'd like to
Rails 2.3.5 I have a table of tickets with each record having a link
I have a table of People, and a table of Service Tickets. Service Tickets
I have a problem. I have a table of support tickets (wh_task). Each task
HI, I have the following table which save agent ranking on daily basis on
I have a table of tickets, common_ticket, with a column called creation_date, which holds

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.