I'm working on a project and I need to solve this problem.
Thank you very much in advance to all of you that can help me.

I have 2 tables 

```
ARTICLE(id,artNum,artType) 
REQUIREDENGINEERS(id,artNum,artType,reqEngineer)

```

All the couples `(artNum,artType)` of `REQUIREDENGINEERS` are in `ARTICLE` but not the contrary.

I give the `ARTICLE ID` as parameter and I need to retrieve the `reqEngineer`.

The problem is that when I don't have the relative `(artNum,artType)` in `REQUIREDENGINEERS` I should use only the artType and take the `max(reqEngineer)`.

I tried but I can't figure it out. Obviously my solution is wrong but maybe something can be saved

```
select (case 
        when t_art.ARTNUM is null then (select max(g.REQENGINEERS) 
                                        from REQUIREDENGINEERS g 
                                        where g.ARTTYPE= t_dur.ARTTYPE)
                                  else t_dur.REQENGINEER
       end) as required_engineers
FROM 
 ARTICLE t_art,
 REQUIREDENGINEERS t_dur
WHERE 
 :id = t_art.ID AND
 t_art.ARTNUM = t_dur.ARTNUM AND 
 t_art.ARTTYPE = t_dur.ARTTYPE;

```