Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: "GROUP BY" - FAQ I've no doubt but I can't find the answer

Re: "GROUP BY" - FAQ I've no doubt but I can't find the answer

From: Phil Singer <psinger1_at_chartermi.net>
Date: Fri, 12 Oct 2001 23:21:35 -0400
Message-ID: <3BC7B33F.EFCC0340@chartermi.net>


Richard Shea wrote:
>
> Well I have already (approx 2001-10-10 01.00 UTC) posted a follow up
> to this thread which doesn't seem to have appeared yet in the NG. I'll
> assume it will appear and go on from there.
>
> Basically I had some difficultities with the approaches suggested and
> I started looking for alternate methods. I seem to have found one by
> writing a function like this ...
>
> CREATE FUNCTION (PAR_ID_IN IN TAS_PARTICIPANT.PAR_AUTOID%TYPE)
> RETURN NUMBER
> IS
> CURSOR PEV_CUR
> IS
> SELECT PEV_PET_EVENT_TYPE,PEV_EVENT_DATETIME
> FROM TAS_PARTICIPANT_EVENT
> WHERE PEV_PAR_ID = PAR_ID_IN
> ORDER BY PEV_EVENT_DATETIME DESC;
>
> latest_Event_Type TAS_PARTICIPANT_EVENT.PEV_PET_EVENT_TYPE%TYPE;
> latest_Event_DateTime TAS_PARTICIPANT_EVENT.PEV_EVENT_DATETIME%TYPE;
>
> BEGIN
> OPEN PEV_CUR;
> FETCH PEV_CUR INTO latest_Event_Type,latest_Event_DateTime;
> CLOSE PEV_CUR;
> RETURN latest_Event_Type;
> END;
I may be missing something here, put if, indeed, PEV_PET_EVENT_TYPE is effectively a constant in each group, all you have to do is wrap it with either a MAX or MIN function in your original query.

> ... I'd still be interested in finding a less clunky way of doing it
> but this at least seems to provide me what I need in the short term.
>
> Thanks for all help and I'd still be interested to hear suggestions to
> the original post.
>
> regards
>
> richard shea.
> rshea_at_my-deja.com

-- 
Phil Singer                |    psinger1_at_chartermi.net
Oracle DBA

Go Wings!!!!!!!
Received on Fri Oct 12 2001 - 22:21:35 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US