Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id C33BC632C16 for ; Wed, 5 Aug 2009 21:05:31 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 65247-09 for ; Thu, 6 Aug 2009 00:05:21 +0000 (UTC) X-Greylist: delayed 00:14:02.942818 by SQLgrey-1.7.6 Received: from smtp2.directcon.net (unknown [207.215.93.5]) by mail.postgresql.org (Postfix) with ESMTP id 48028632840 for ; Wed, 5 Aug 2009 21:05:21 -0300 (ADT) X-ASG-Debug-ID: 1249516273-54b500570000-hAWazd X-Barracuda-URL: http://207.215.93.5:8000/cgi-bin/mark.cgi Received: from [192.168.1.219] (statics-76-14-161-10.wsac.wavecable.com [76.14.161.10]) by smtp2.directcon.net (Spam Firewall) with ESMTP id D1C6D85A56A for ; Wed, 5 Aug 2009 16:51:13 -0700 (PDT) Received: from [192.168.1.219] (statics-76-14-161-10.wsac.wavecable.com [76.14.161.10]) by smtp2.directcon.net with ESMTP id pKcCi7qexVZGR7X0 for ; Wed, 05 Aug 2009 16:51:13 -0700 (PDT) From: John To: "pgsql-sql@postgresql.org" X-ASG-Orig-Subj: two records per row from query Subject: two records per row from query Date: Wed, 5 Aug 2009 16:51:13 -0700 User-Agent: KMail/1.9.9 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200908051651.13235.jfabiani@yolo.com> X-Barracuda-Connect: statics-76-14-161-10.wsac.wavecable.com[76.14.161.10] X-Barracuda-Start-Time: 1249516273 X-Barracuda-Virus-Scanned: by Sierra Advantage Inc. at directcon.net X-Barracuda-Spam-Score: 0.00 X-Barracuda-Spam-Status: No, SCORE=0.00 using global scores of TAG_LEVEL=1000.0 QUARANTINE_LEVEL=9.0 KILL_LEVEL=9.0 tests= X-Barracuda-Spam-Report: Code version 3.2, rules version 3.2.2.5400 Rule breakdown below pts rule name description ---- ---------------------- -------------------------------------------------- X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.64 tagged_above=-10 required=5 tests=BAYES_20=-0.74, RDNS_NONE=0.1 X-Spam-Level: X-Archive-Number: 200908/16 X-Sequence-Number: 32925 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