Re: More wacky grouping

From: Josh Berkus <josh(at)agliodbs(dot)com>
To: "James Taylor" <jtx(at)hatesville(dot)com>, <pgsql-sql(at)postgresql(dot)org>
Subject: Re: More wacky grouping
Date: 2003-04-04 00:42:16
Message-ID: 200304031642.16094.josh@agliodbs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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 Berkus
Aglio Database Solutions
San Francisco

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Walter McGinnis 2003-04-04 01:10:41 Re: pesky plpgsql
Previous Message James Taylor 2003-04-04 00:29:08 More wacky grouping