From: | Michael Glaesemann <grzm(at)myrealbox(dot)com> |
---|---|
To: | Sean Davis <sdavis2(at)mail(dot)nih(dot)gov> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Normalized storage to denormalized report |
Date: | 2006-01-19 12:23:58 |
Message-ID: | 75A38F56-726A-4F8C-A006-0846205A2A93@myrealbox.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Jan 19, 2006, at 21:03 , Sean Davis wrote:
> I have a table that stores data like so:
>
> Create table raw_vals (
> expt_id int,
> clone_idx int,
> val numeric,
> primary key (expt_id,clone_idx)
> );
>
> And I would like to design a query that gives:
>
> Clone_idx expt_id_1 expt_id_2 ....
> 1 0.7834 0.8231 ....
> 2 0.2832 1.2783 ....
>
> There are several tens-of-thousands of clone_idx entries, so doing
> this
> quickly may not even be possible. Any suggestions on how to go
> from this
> normalized structure to the denormalized form easily. Note that
> this isn't
> exactly a crosstab, since there is no counting data, just reshaping.
As far as I know, the crosstab functions in contrib/tablefunc will
still do what you want. Another way is to have as many (self) joins
as you want columns.
Michael Glaesemann
grzm myrealbox com
From | Date | Subject | |
---|---|---|---|
Next Message | A. Kretschmer | 2006-01-19 12:40:10 | Re: Insert a default timestamp when nothing given |
Previous Message | Martijn van Oosterhout | 2006-01-19 12:14:35 | Re: Normalized storage to denormalized report |