|
|
src: |
|
|
|
SELECT 'M'::text ||
|
|
|
CASE
|
|
|
WHEN (p_calendrier_mois_1.mois - p_calendrier_mois.mois + 1::numeric) <= 12::numeric THEN 12::numeric - (p_calendrier_mois_1.mois - p_calendrier_mois.mois)
|
|
|
ELSE 12::numeric - (p_calendrier_mois_1.mois - p_calendrier_mois.mois + 1::numeric - 89::numeric)
|
|
|
END::text AS code,
|
|
|
p_calendrier_mois.texte_court AS texte,
|
|
|
p_calendrier_mois.mois,
|
|
|
p_calendrier_mois_1.mois AS dernier_mois
|
|
|
FROM base.p_calendrier_mois,
|
|
|
base.p_calendrier_mois p_calendrier_mois_1
|
|
|
WHERE p_calendrier_mois_1.mois >= p_calendrier_mois.mois AND (p_calendrier_mois_1.mois - p_calendrier_mois.mois) <= 99::numeric
|
|
|
UNION
|
|
|
SELECT 'N'::text ||
|
|
|
CASE
|
|
|
WHEN (p_calendrier_mois_1.mois - p_calendrier_mois.mois + 1::numeric) <= 12::numeric THEN 12::numeric - (p_calendrier_mois_1.mois - p_calendrier_mois.mois)
|
|
|
ELSE 12::numeric - (p_calendrier_mois_1.mois - p_calendrier_mois.mois + 1::numeric - 89::numeric)
|
|
|
END::text AS code,
|
|
|
to_char(p_calendrier_mois.mois, 'FM999999'::text) AS texte,
|
|
|
p_calendrier_mois.mois,
|
|
|
p_calendrier_mois_1.mois AS dernier_mois
|
|
|
FROM base.p_calendrier_mois,
|
|
|
base.p_calendrier_mois p_calendrier_mois_1
|
|
|
WHERE p_calendrier_mois_1.mois >= p_calendrier_mois.mois AND (p_calendrier_mois_1.mois - p_calendrier_mois.mois) <= 99::numeric
|
|
|
ORDER BY 4, 3;
|