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
Are we doing some homework here ? :)
Anyway this is one solution
select Name, age
from your_table y
where rowid = (select rowid from your_table y2
where rownum < 2 and y.age = y2.age);
is this really what you wanted ? This will take the first occurance the program finns at a certain age and output the result.
If you want all occurances only printed once like if you had
Brandon, 12
Walsh, 12
Brenda, 12
Brenda, 12
Then the soultion would be
select name, age from your_table
group by age, name;
Brandon, 12
Walsh, 12
Brenda, 12
Regards
/Joachim
Lee Gwun Wai <gwunwai_at_pacific.net.sg> wrote in article
<6beuth$5of$1_at_newton.pacific.net.sg>...
> 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
>
>
>
Received on Mon Feb 09 1998 - 00:00:00 CST
![]() |
![]() |