1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| With offres (code_offre, libelle_offre) AS
(
select 'O1', 'Lib O1' union all
select 'O2', 'Lib O2' union all
select 'O3', 'Lib O3'
)
, obectifs (obj, code_offre, num_semaine, annee) AS
(
select 1, 'O1', '11', '2010' union all
select 2, 'O1', '11', '2011' union all
select 3, 'O2', '12', '2010' union all
select 4, 'O3', '11', '2010' union all
select 5, 'O4', '11', '2010'
)
SELECT ofr.libelle_offre, obj.obj
FROM offres ofr
LEFT OUTER JOIN obectifs obj
ON ofr.code_offre = obj.code_offre
AND obj.num_semaine = '11'
AND obj.annee = '2010';
libelle_offre obj
------------- -----------
Lib O1 1
Lib O2 NULL
Lib O3 4 |
Partager