Subject Re: [ib-support] DISTINCT on only one field?
Author Dimitry Sibiryakov
On 28 Apr 2003 at 9:26, Joe Martinez wrote:

>I have a table with addresses:
>
>Name
>Address
>City
>State
>Zip
>
>I want to do a select that only picks up distinct values of the
>Address and Zip fields, but I want the select to include the rest of
>the fields. If the same value pair of Address and Zip appears more
>than once, I only want one of the records, even if the rest of the
>fields differ. I don't care which one of the records I get.

Ok. Your need is rather strange, but I think this query may help:

Select Address, Zip, max(Name), max(City), Max(State) from table
group by Address, Zip

In this case you'll get Name from one record, City from other and
State from third, but as you stated above - you don't care. :)
If you however care - use SP suggested by A.Nevsky.

SY, Dimitry Sibiryakov.