agora inbox for pgsql-sql@postgresql.org  
help / color / mirror / Atom feed
Formatting query result like a calendar
2+ messages / 2 participants
[nested] [flat]

* Formatting query result like a calendar
@ 2014-04-04 12:34  dahd101+hm3ufk@guerrillamail.com
  0 siblings, 1 reply; 2+ messages in thread

From: dahd101+hm3ufk@guerrillamail.com @ 2014-04-04 12:34 UTC (permalink / raw)
  To: pgsql-sql

Hi, 

I have a query result that comes out as follows (this is an excerpt, the whole thing shows a whole month):

Date   ID    Day
31/03   1    Mon
01/04   0    Tue
02/04   1    Wed
03/04   1    Thu
04/04   0    Fri
07/04   1    Mon
08/04   0    Tue
09/04   1    Wed
10/04   1    Thu
11/04   0    Fri

I need it in the format:

Date      Mon   Tue   Wed  Thu  Fri
31/03      1     0     1    1    0
07/04      1     0     1    1    0


Any ideas?

Thanks!
Jen





----
Sent using GuerrillMail.com
Block or report abuse: https://www.guerrillamail.com/abuse/?a=UUZnFAFNUKUZqB6742oYYBHUXMbe3cVX





-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-sql



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Formatting query result like a calendar
@ 2014-04-04 14:43  Jan Ostrochovsky <ostrochovsky@mobiletech.sk>
  parent: dahd101+hm3ufk@guerrillamail.com
  0 siblings, 0 replies; 2+ messages in thread

From: Jan Ostrochovsky @ 2014-04-04 14:43 UTC (permalink / raw)
  To: dahd101+hm3ufk@guerrillamail.com; +Cc: pgsql-sql

Hi Jen, 


what you need is called transposition - look for crosstab (part of tablefunc). 


http://www.postgresql.org/docs/9.3/static/tablefunc.html 


Jano Ostrochovsky 

----- Original Message -----


From: dahd101+hm3ufk@guerrillamail.com 
To: pgsql-sql@postgresql.org 
Sent: Friday, April 4, 2014 2:34:07 PM 
Subject: [SQL] Formatting query result like a calendar 

Hi, 

I have a query result that comes out as follows (this is an excerpt, the whole thing shows a whole month): 

Date ID Day 
31/03 1 Mon 
01/04 0 Tue 
02/04 1 Wed 
03/04 1 Thu 
04/04 0 Fri 
07/04 1 Mon 
08/04 0 Tue 
09/04 1 Wed 
10/04 1 Thu 
11/04 0 Fri 

I need it in the format: 

Date Mon Tue Wed Thu Fri 
31/03 1 0 1 1 0 
07/04 1 0 1 1 0 


Any ideas? 

Thanks! 
Jen 





---- 
Sent using GuerrillMail.com 
Block or report abuse: https://www.guerrillamail.com/abuse/?a=UUZnFAFNUKUZqB6742oYYBHUXMbe3cVX 





-- 
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) 
To make changes to your subscription: 
http://www.postgresql.org/mailpref/pgsql-sql 

^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2014-04-04 14:43 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2014-04-04 12:34 Formatting query result like a calendar dahd101+hm3ufk@guerrillamail.com
2014-04-04 14:43 ` Jan Ostrochovsky <ostrochovsky@mobiletech.sk>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox