Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Select Family, First (Name) from ... group by Family
The problem you are having is that
you appear to be familiar with spreadsheets,
and the thing that Joe Celko (I think) once called
an arcade game, but not relational databases.
There is no such thing as the 'first'
row a relational system - there is only
a data value which allows you to
identify the row your are interested in.
>>> Family Name
>>> ------------- ------------
>>> Smith John
>>> Smith Roger
>>> Smith Bob
>>> Doe Arthur
>>> Doe John
>>> Souvlaki Angie
>>> Souvlaki Benny
If you wish to claim (arbitrarily) that
Smith, John is the 'first' member of
the family, then you will need to hold
a data item (such as 'position in family')
with the value 1.
Your query is then:
select * from family
where position_in_family = 1;
N.B. For a friendlier answer, try
a more positive approach.
--
Jonathan Lewis
Yet another Oracle-related web site: http://www.jlcomp.demon.co.uk
Patrick Joyal wrote in message <38b44f61_at_news>...
>I would get something that look like what I want, but suppose I add an
other
>column, Weight
>
>so if I have :
>
>Family Name Weight
>--------------- ------------ ----------
>Smith John 5'10"
>Smith Roger 4' 9"
>
>it would give :
>
>Smith Roger 5'10"
>
>but I would prefer to have :
>
>Smith John 5'10"
>
>because what I want is the first record from each group, no matter wich
>record it is, BUT the values from that record
>have to come from the same row, you see?
>
>so, if anybody can help, I can't believe Oracle never thought of that ?
>
>thanks
>
>Patrick
>
>Thomas Olszewicki wrote in message ...
>>Try this:
>>
>>Select Family,Max(Name) from People Group By Family.
>>Thomas.
>>
>>
>>"Patrick Joyal" <please.reply_at_to.the.newsgroup> wrote in message
>>news:38b4438f_at_news...
>>>
>>> here's an example to understand my problem.
>>>
>>> I have a table People containing 2 columns : Family and Name
>>>
>>>
>>> Family Name
>>> ------------- ------------
>>> Smith John
>>> Smith Roger
>>> Smith Bob
>>> Doe Arthur
>>> Doe John
>>> Souvlaki Angie
>>> Souvlaki Benny
>>>
>>>
>>> in Access, if I want 1 member from each family, I use this :
>>>
>>> Select Family, First (Name)
>>> from People
>>> Group By Family
>>>
>>> results :
>>>
>>> Family Name
>>> ------------- -----------
>>> Smith John
>>> Doe Arthur
>>> Souvlaki Angie
>>>
>>>
>>> How could I do this in Oracle ?
>>>
>>> merci
>>>
>>> Patrick
>>>
>>>
>>
>>
>
>
Received on Wed Feb 23 2000 - 15:54:53 CST
![]() |
![]() |