jueves, 10 de marzo de 2016
Obtener Trimestre
/*
select * from sp_obtener_trimestre(7);
select * from sp_obtener_trimestre(11);
select * from sp_obtener_trimestre(3);
*/
create or replace function sp_obtener_trimestre(p_num_mes int)
returns int
as $$
declare
v_trim int = 1;
begin
if(p_num_mes = 1 or p_num_mes = 2 or p_num_mes = 3)then
return 1;
end if;
if(p_num_mes = 4 or p_num_mes = 5 or p_num_mes = 6)then
return 2;
end if;
if(p_num_mes = 7 or p_num_mes = 8 or p_num_mes = 9)then
return 3;
end if;
if(p_num_mes = 10 or p_num_mes = 11 or p_num_mes = 12)then
return 4;
end if;
end;
$$ language plpgsql;
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario