Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: -> Help me w/this built-in function!
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 CDT