Re: Slick Query

From: hpuxrac <>
Date: Sat, 26 Jul 2008 10:13:33 -0700 (PDT)
Message-ID: <>

On Jul 25, 1:06 pm, wrote:
> I want to see if I can create a slick query to do this and cut down on
> some code.
> I have a list of dates & statuses like this:
> 01/05/08 Complete
> 02/15/09 Complete
> 02/18/08 Active
> 05/10/08 Cancelled
> 06/07/08 Pending
> 02/19/08 Complete
> I'll order them in the query.  What I need to do is first check to see
> if there is a status of Active or Pending and return the first one I
> encounter.  If those do not exist, I need to return the first Complete
> or Cancelled I encounter.
> In this case Active would be returned.
> Right now I have a cursor and some PL/SQL going through 2 loops
> checking for Active/Pending, then Complete/Cancelled.  I'd like to see
> if I can do it all in one query.
> Any hopes of doing this?

It's always helpful if you note what version of oracle you are running ... that way if people take the time to suggest a SQL query to give you what you want ... it might actually work.

Certainly you can and should do it in 1 SQL statement but there are various tricks that may not be applicable depending on version. Received on Sat Jul 26 2008 - 12:13:33 CDT

Original text of this message