Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: help : select unique values of a non-key field, tia
On Fri, 6 Feb 1998 20:17:54 +0800, "Lee Gwun Wai" <gwunwai_at_pacific.net.sg>
wrote:
Hi Gwun,
assuming your table has a pk generated by a sequence, try:
SELECT a.name,a.age
from table a, (Select MIN(pk-field) min, age from table group by age) b
where
a.pk-field = b.min
AND
a.age=b.age
order by age,name;
-- Regards Matthias GreszReceived on Fri Feb 06 1998 - 00:00:00 CST
>Hello everybody,
>
>How do I select unique values of a field that is not a key?
>
>For example, a Persons table with fields (Name, Age,....) where we can have
>more than 1 person sharing the same age.
>
>I want to get 1 name for every age there is in the table. 1 name for age 10,
>1 name for age 11,....
>
>Thanks in advance,
>Gwun Wai
>
>
-- Regards Matthias Gresz :-)