pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: James Taylor <jtx@hatesville.com>
To: pgsql-sql@postgresql.org
Subject: Re: More wacky grouping
Date: Thu, 3 Apr 2003 16:42:16 -0800
Message-ID: <200304031642.16094.josh@agliodbs.com> (raw)
In-Reply-To: <002601c2fa41$3a88d760$4500a8c0@theplague>
References: <002601c2fa41$3a88d760$4500a8c0@theplague>

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




view thread (4+ messages)  latest in thread

Message-ID: <200304031642.16094.josh@agliodbs.com>
Permalink:  ../200304031642.16094.josh@agliodbs.com/
Also on:    postgresql.org/message-id/200304031642.16094.josh@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com, jtx@hatesville.com
  Subject: Re: More wacky grouping
  In-Reply-To: <200304031642.16094.josh@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox