Received: from dfw-ix8.ix.netcom.com (dfw-ix8.ix.netcom.com [206.214.98.8]) by hub.org (8.8.8/8.8.8) with ESMTP id CAA00980 for ; Fri, 18 Sep 1998 02:40:27 -0400 (EDT) (envelope-from wleeke@ix.netcom.com) Received: (from smap@localhost) by dfw-ix8.ix.netcom.com (8.8.4/8.8.4) id BAA28836 for ; Fri, 18 Sep 1998 01:39:53 -0500 (CDT) Received: from chw-il7-24.ix.netcom.com(198.211.138.152) by dfw-ix8.ix.netcom.com via smap (V1.3) id rma028826; Fri Sep 18 01:39:30 1998 Message-ID: <36020019.F0178A9D@ix.netcom.com> Date: Fri, 18 Sep 1998 01:39:21 -0500 From: William Leeke X-Mailer: Mozilla 4.04 [en] (Win95; U) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: SQL equiv to MS-Access Transform Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit ver: postgresql-6.2.1-7 OK, Ive been looking for solution for about 8 hours straight now and my head hurts. Is it possible to do this ... TRANSFORM Statement Examples SQL statement Description PARAMETERS [Sales for which year?] LONG; TRANSFORM Sum([Order Details].Quantity * ([Order Details]. [Unit Price] - ([Order Details].Discount / 100) * [Order Details]. [Unit Price])) AS Sales SELECT [Product Name] FROM Orders INNER JOIN (Products INNER JOIN [Order Details] ON Products.[Product ID] = [Order Details].[Product ID]) ON Orders.[Order ID] = [Order Details].[Order ID] WHERE DatePart("yyyy", [Order Date]) = [Sales for which year?] GROUP BY [Product Name] ORDER BY [Product Name] PIVOT DatePart("m", [Order Date]); Creates a crosstab query that shows product sales by month for a user-specified year. The months are displayed from left to right (pivoted) as columns, and the product names are displayed from top to bottom as rows. ...with in postgres? If this is a sore subject, I appologize ahead of time. If this is referenced in a FAQ somewhere, please point the way. Pivoting time data from rows to columns *seems to be a common if non-intuitive thing to do with a database. :) thanks, wbl -- "If you're not supposed to eat animals, why are they made of meat?" :)