You are on page 1of 1

select c.fecha_cit,(case when extract (month from c.

fecha_cit)= 01 then 'Enero'


when
when
when
when
when
when
when
when

extract
extract
extract
extract
extract
extract
extract
extract

(month
(month
(month
(month
(month
(month
(month
(month

from
from
from
from
from
from
from
from

c.fecha_cit)=
c.fecha_cit)=
c.fecha_cit)=
c.fecha_cit)=
c.fecha_cit)=
c.fecha_cit)=
c.fecha_cit)=
c.fecha_cit)=

02
03
04
05
06
07
08
09

then
then
then
then
then
then
then
then

'Febrero'
'Marzo'
'Abril'
'Mayo'
'Junio'
'Julio'
'Agosto'
'Septiembre'

when extract (month from c.fecha_cit)= 10 then 'Octubre'


when extract (month from c.fecha_cit)= 11 then 'Noviembre'
when extract (month from c.fecha_cit)= 12 then 'Diciembre'
end ):: varchar(100) as fecha_cita,
(p.apellidos_p ||','|| p.nombres_p)as apellidos_nombres,
serv.descripcion_serv as estudio,
(doc.apellidos_d||','||doc.nombres_d) as medico,
conv.descripcion_conv as procedencia,
dc.comision_doctor as comision
from cita c
inner join detalle_cita dc on (dc.codigo_t_c=c.codigo_t_
c and dc.codigo_f_p=c.codigo_f_p and dc.codigo_p=c.codigo_p and dc.num_comproban
te_cita=c.num_comprobante_cita)
inner join paciente p on (p.codigo_p = c.codigo_p)
inner join servicio serv on (serv.codigo_serv =dc.codigo
_serv)
inner join doctor doc on (doc.codigo_d=c.codigo_d)
inner join convenio conv on (conv.codigo_conv = dc.codig
o_conv)
WHERE
extract(year from c.fecha_cit)='2015' and
extract (month from c.fecha_cit)='08' and
doc.codigo_d=1
order by
1;

You might also like