--- James Orr <[EMAIL PROTECTED]> wrote:
> I think he might be talking about mine. The region
> values will not be
> duplicated, the WHERE clause prevents it.
If you are saying that I didn't read the original
query closely enough, you're probably right.
Unfortunately I deleted the original me
> > BTW, I don't believe the self-join approach proposed
> > earlier will work, because joining on "scanid" will
> > create a cartesian type join where the region values
> > will be duplicated (multiplicated!).
>
> Not if you're talking about my query, they won't. I use that query form
> in many
Jeff,
> I don't see how you got the result you quote below.
> My query sums the volume figures, grouping by scanid:
> that worked as expected (one line per scanid) on my
> system when I tested it (version 7.1.2, though I don't
> think that matters).
Lemme try it
Yes, you're right. Sorry!
Josh,
I don't see how you got the result you quote below.
My query sums the volume figures, grouping by scanid:
that worked as expected (one line per scanid) on my
system when I tested it (version 7.1.2, though I don't
think that matters).
Jeff
--- Josh Berkus <[EMAIL PROTECTED]> wrote:
> Of co
Jeremy,
> I see how your idea could work--the only thing I would change would
> be region needs to be scanid on the first line; however,
> I'm using PostgreSQL v7.03, so I can not do subqueries within FROM
> clause.
>
> Other than creating a temporary table, is there a way to
> restructure this
Jeff,
> SELECT
>scanid,
>sum ( CASE WHEN region = 'A' THEN volume ELSE NULL
> )
> AS A_volume,
>sum ( CASE WHEN region = 'B' THEN volume ELSE NULL
> )
> AS B_volume,
>sum ( CASE WHEN region = 'C' THEN volume ELSE NULL
> )
> AS C_volume
> FROM table
> GROUP BY scanid
H Jeremy Bockholt schreef:
> I have a generalized table:
>
> scanid | region | volume
> -
> 1 A 34.4
> 1 B 32.1
> 1 C 29.1
> 2 A 32.4
> 2 B 33.2
> 2 C 35.6
> .
> .
> .
>
> I want to creat
Hi,
I see how your idea could work--the only thing I would change would
be region needs to be scanid on the first line; however,
I'm using PostgreSQL v7.03, so I can not do subqueries within FROM clause.
Other than creating a temporary table, is there a way to
restructure this solution to get aro
I think this might do the trick...
CREATE FUNCTION hori_view() RETURNS BOOLEAN AS '
DECLARE
view_select TEXT;
view_from TEXT;
view_where TEXT;
column_name TEXT;
last_column_name TEXT;
g_row generalized_table%ROWTYPE;
BEGIN
Jeremy,
First, to do a pivot table, you have to be using Postgres 7.1.x. 7.0.x
will not do it. So upgrade now.
> I want to create a flattened out view that looks like the following:
>
> scanid | A_volume | B_volume | C_volume
>
> 134.4
- Original Message -
From: "H Jeremy Bockholt" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, October 30, 2001 7:36 PM
Subject: [SQL] transposing data for a view
> I have a generalized table:
>
> scanid | region | volume
> --
I have a generalized table:
scanid | region | volume
-
1 A 34.4
1 B 32.1
1 C 29.1
2 A 32.4
2 B 33.2
2 C 35.6
.
.
.
I want to create a flattened out view that looks like the following:
sca
I want the values in column label to be displayed in the a-axis. Is
there an easy way to transform the data:
Here is the input data:
age_code | label | count
--+---+---
age_1| 30k | 1
age_1| 50k | 2
age_1| more | 2
age_2| 40k | 2
age_3
13 matches
Mail list logo