Re: -> Help me w/this built-in function!

From: Eric Byrnes <LNUSMCD.NZJDDV_at_eds.com>
Date: 1996/10/25
Message-ID: <3271672B.4289_at_eds.com>#1/1


I think what you're after is something like:

   select e.id, e.lastname, e.firstname,

      decode(count(*),3,'Qualified','Not Qualified')    from employee e, qualifications q
   where e.id = q.id (+)
   group by e.id, e.lastname, e.firstname;

The decode expression cannot be a full SELECT statement. It has to be a valid expression such as a column, function call, fixed value, math expression, or whatever.
You will probably also need the outer join if you want to properly list employees that have no entries in qualifications.

Eric

Les Gainous wrote:
>
> I'm new to Oracle (but not new to SQL databases) and wonder...why can't I do the following with the DECODE() function?:
>
> select e.id
> e.lastname,
> e.firstname
> decode((select count(*) from qualifications q where q.id = e.id),3,'Qualified','Not Qualified')
> from employee e
>
Received on Fri Oct 25 1996 - 00:00:00 CEST

Original text of this message