Re: More wacky grouping - Mailing list pgsql-sql

From Josh Berkus
Subject Re: More wacky grouping
Date
Msg-id 200304031642.16094.josh@agliodbs.com
Whole thread Raw
In response to More wacky grouping  ("James Taylor" <jtx@hatesville.com>)
List pgsql-sql
James,

> I need to do grouping based on various aggregates, but the way my table
> is set up (it can't change) is making things kind of difficult.

Yeah.   You should track down the previous database designer and break his
fingers ....

Anyway, you'll need to work through subselects.   That is, subselect each
datatype from the table as if it were a seperate table and join them, e.g.

FROM (SELECT content, id_customer FROM table1 WHERE id_datatype = 2) tb2,(SELECT content, id_customer FROM table1 WHERE
id_datatype= 3) tb3 
etc.

Also, since you'll be summing on a text field which is being converted to
NUMERIC on the fly, expect your query to be slow as molasses.

--
-Josh BerkusAglio Database SolutionsSan Francisco



pgsql-sql by date:

Previous
From: "James Taylor"
Date:
Subject: More wacky grouping
Next
From: Walter McGinnis
Date:
Subject: Re: pesky plpgsql