From: | Aland Laines <aland(dot)laines(at)gmail(dot)com> |
---|---|
To: | Cesar Erices <caerices(at)gmail(dot)com> |
Cc: | POSTGRES <pgsql-es-ayuda(at)postgresql(dot)org> |
Subject: | Re: Rehacer consulta |
Date: | 2014-02-05 18:58:20 |
Message-ID: | CABk_u6R4-9Q1xR7baayCCoYgH7dC_kaMqWx=-P_=oaRjNSV+8w@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-es-ayuda |
Hola, en realidad lo que deseo es distinto: si te das cuenta, en mi
consulta me devuelve:
Year Month Genero Cantidad
2013 1 M 145
2013 1 F 55
2013 2 M 122
2013 2 F 100
pero lo que necesito en realidad es
Year Month Masculino Femenino Total
2013 1 145 55 200
2013 2 122 100 222
Gracias de antemano por su ayuda,
*Aland Laines Calonge*
Twitter: @lainessolutions
Comunidad CakePHP en Español
Google+<https://plus.google.com/communities/106077549014949879129>
http://about.me/aland.laines
2014-02-05 Cesar Erices <caerices(at)gmail(dot)com>:
> SELECT date_part('YEAR',"Postulante".
> created) AS "Postulante__year", date_part('MONTH',"Postulante".created) AS
> "Postulante__month", "Persona".genero AS "Postulante__genero",
> count("Postulante".id) AS "Postulante__cuenta"
> FROM "produccion"."postulantes" AS "Postulante" LEFT JOIN
> "produccion"."personas" AS "Persona" ON ("Postulante"."persona_id" =
> "Persona"."id")
> WHERE "Postulante"."estado" = 1 AND date_part('YEAR',"Postulante".created)
> = '2013'
> GROUP BY "Persona"."genero", date_part('YEAR',"Postulante"."created"),
> date_part('MONTH',"Postulante"."created")
> ORDER BY date_part('YEAR',"Postulante".created) ASC,
> date_part('MONTH',"Postulante".created) ASC
>
>
> En la parte "Persona".genero AS "Postulante__genero" reelmplazar por CASE "Persona".genero
> WHEN M THEN 'Masculino' ELSE 'Femenino' END AS "Postulante__genero"
>
>
> --
> Sin más que decir se despide de Usted, muy atentamente
>
> Cesar Erices Vergara
> Ingeniero en Gestión Informática
> Analista de Sistema
> Especialista en ISO 27001 e ITIL
>
> Cuenta Twitter: @caerices
>
> Santiago - Chile
>
From | Date | Subject | |
---|---|---|---|
Next Message | Fernando Hevia | 2014-02-05 19:29:09 | Re: Rehacer consulta |
Previous Message | Cesar Erices | 2014-02-05 18:47:32 | Re: Rehacer consulta |