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