Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WW5Lf-0002Sl-GP for pgsql-sql@arkaria.postgresql.org; Fri, 04 Apr 2014 14:44:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WW5Lf-0003cm-0S for pgsql-sql@arkaria.postgresql.org; Fri, 04 Apr 2014 14:44:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WW5Ld-0003cf-UN for pgsql-sql@postgresql.org; Fri, 04 Apr 2014 14:44:01 +0000 Received: from zimbra.isdd.sk ([91.233.248.204]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WW5LW-0007GE-If for pgsql-sql@postgresql.org; Fri, 04 Apr 2014 14:44:01 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by zimbra.isdd.sk (Postfix) with ESMTP id 72F42AC857C; Fri, 4 Apr 2014 16:43:53 +0200 (CEST) X-Virus-Scanned: amavisd-new at zimbra.isdd.sk Received: from zimbra.isdd.sk ([127.0.0.1]) by localhost (zimbra.isdd.sk [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8w-Vtix8cWM4; Fri, 4 Apr 2014 16:43:52 +0200 (CEST) Received: from zimbra.isdd.sk (zimbra.isdd.sk [91.233.248.204]) by zimbra.isdd.sk (Postfix) with ESMTP id EEF98AC8562; Fri, 4 Apr 2014 16:43:52 +0200 (CEST) Date: Fri, 4 Apr 2014 16:43:52 +0200 (CEST) From: Jan Ostrochovsky To: dahd101+hm3ufk@guerrillamail.com Cc: pgsql-sql@postgresql.org Message-ID: <264572247.1712456.1396622632842.JavaMail.root@mobiletech.sk> In-Reply-To: <779cbb18a1d78ad415d8faf6ba1dc9bbcd39@guerrillamail.com> Subject: Re: Formatting query result like a calendar MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_1712455_2016659664.1396622632842" X-Originating-IP: [10.8.253.141] X-Mailer: Zimbra 7.2.6_GA_2926 (ZimbraWebClient - GC33 (Win)/7.2.6_GA_2926) X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org ------=_Part_1712455_2016659664.1396622632842 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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 ------=_Part_1712455_2016659664.1396622632842 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable <= div style=3D'font-family: times new roman,new york,times,serif; font-size: = 12pt; color: #000000'>Hi Jen,

what you need is called transposition - l= ook for crosstab (part of tablefunc).

h= ttp://www.postgresql.org/docs/9.3/static/tablefunc.html

= Jano Ostrochovsky

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

Hi,

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

Date   ID    Day
31/03   1    Mon<= br>01/04   0    Tue
02/04   1    Wed
03= /04   1    Thu
04/04   0    Fri
07/04 &= nbsp; 1    Mon
08/04   0    Tue
09/04  = 1    Wed
10/04   1    Thu
11/04   0 &n= bsp;  Fri

I need it in the format:

Date     &n= bsp;Mon   Tue   Wed  Thu  Fri
31/03     &n= bsp;1     0     1    1    0
07/0= 4      1     0     1    1 &nbs= p;  0


Any ideas?

Thanks!
Jen




<= br>----
Sent using GuerrillMail.com
Block or report abuse: https://ww= w.guerrillamail.com/abuse/?a=3DUUZnFAFNUKUZqB6742oYYBHUXMbe3cVX


=


--
Sent via pgsql-sql mailing list (pgsql-sql@postgresql.or= g)
To make changes to your subscription:
http://www.postgresql.org/ma= ilpref/pgsql-sql

------=_Part_1712455_2016659664.1396622632842--