X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 460EBD1B518 for ; Mon, 20 Oct 2003 17:13:26 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 68270-04 for ; Mon, 20 Oct 2003 14:12:56 -0300 (ADT) Received: from anchor-post-35.mail.demon.net (anchor-post-35.mail.demon.net [194.217.242.85]) by svr1.postgresql.org (Postfix) with ESMTP id 7964DD1B4F6 for ; Mon, 20 Oct 2003 14:12:52 -0300 (ADT) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by anchor-post-35.mail.demon.net with esmtp (Exim 3.35 #1) id 1ABdaO-0007EQ-0Z; Mon, 20 Oct 2003 18:12:52 +0100 Received: from localhost (localhost.localdomain [127.0.0.1]) by mainbox.archonet.com (Postfix) with ESMTP id 0B51C182E6; Mon, 20 Oct 2003 18:12:51 +0100 (BST) Received: from client17.archonet.com (client17.archonet.com [192.168.1.17]) by mainbox.archonet.com (Postfix) with ESMTP id 48EBF17244; Mon, 20 Oct 2003 18:12:50 +0100 (BST) From: Richard Huxton To: Adam Witney , pgsql-sql Subject: Re: query or design question Date: Mon, 20 Oct 2003 18:12:49 +0100 User-Agent: KMail/1.5 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200310201812.49869.dev@archonet.com> X-Virus-Scanned: by AMaViS snapshot-20020531 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/240 X-Sequence-Number: 15640 On Monday 20 October 2003 11:58, Adam Witney wrote: > Hi, > > I have a table like so > > CREATE TABLE imagene ( > id int > bioassay_id int > gene_id text > s_row int > s_column int > s_meta_row int > s_meta_column int > sig_median numeric > bkg_median numeric > ); > And I need to generate an output like this...... > > bioassay_id=106 bioassay_id=107 > ---------------------- ---------------------- > gene_id, sig_median, bkg_median, sig_median, bkg_median > I am not sure if a crosstab function will do this? There are some examples in contrib/tablefunc that might well be useful for you. You should also check out the "Set Returning Functions" article on http://techdocs.postgresql.org/ If you find your requirements getting particularly complex, I'd be tempted to do the hard work in the application. -- Richard Huxton Archonet Ltd