pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: John <jfabiani@yolo.com>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: two records per row from query
Date: Wed, 5 Aug 2009 16:51:13 -0700
Message-ID: <200908051651.13235.jfabiani@yolo.com> (raw)

mytable
pkid
class_date.
sessionid

select * from mytable
1 2009/01/01 2101
2 2009/01/02 2101

I would like an SQL that would produce

newtable
pkid,
class_date1,
class_date2,
sessionid1,
sessionid2

Select * from newtable

1 2009/01/01 2009/01/02 2101 2101

I have a list of classes that is perfect for our needs.  However, I need to 
create the second table (from a query) to feed to a report writer so it can 
write out a single line of text for two records.
Like:

Your class dates are as follows

   Date              Date
01/01/2009           01/02/2009
01/08/2009           01/10/2009
03/31/2009           04/05/2009
and will continue until the all the classes are printed.

The problem of course is the table has a row per class and the report writer 
needs two class dates per row.

I have no idea how to do this using SQL.

Thanks in advance,
Johnf



view thread (8+ messages)  latest in thread

Message-ID: <200908051651.13235.jfabiani@yolo.com>
Permalink:  ../200908051651.13235.jfabiani@yolo.com/
Also on:    postgresql.org/message-id/200908051651.13235.jfabiani@yolo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: jfabiani@yolo.com
  Subject: Re: two records per row from query
  In-Reply-To: <200908051651.13235.jfabiani@yolo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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