I am working in SQL Server 2008 R2. I have a table in which 1 "record" is actually several records due to one of its fields having different values. This table has a lot of fields itself. All of the fields for a given "record" will have the same value, except for the one field that has various values. I want to query all records and return all fields, but I want only 1 instance (the first one) of each "record". For example, my table looks like:
Field 1 Field 2 Field 3
value a value x value 1
value a value x value 2
value a value x value 3
value b value y value 20
value b value y value 21
value b value y value 22
I want my query to return something like:
Field 1 Field 2 Field 3
value a value x value 1
value b value y value 20
So, my Field 1 is my key. Normally, I would just do a SELECT DISTINCT. However, since I want all fields to return in the query, the DISTINCT will apply to all of the fields in the SELECT, which means that all records will return, rather than just 1 for each key. What is the best way of accomplishing this?