Subject Re: DISTINCT on only one field?
Author Alexander V.Nevsky
--- In ib-support@yahoogroups.com, Joe Martinez <joe@j...> wrote:
> Here's my situation:
>
> 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.

Joe, I recommend to think about selectable stored procedure like

For Select Distinct Address, Zip
...
Into :Address, :Zip
Do
begin
Select First 1 Name, City, State ...
...
Where Address=:Address And Zip=:Zip
Into ...
Suspend;
end

Best regards, Alexander V.Nevsky.