From: Joe Conway <mail@joeconway.com>
To: James Taylor <jtx@hatesville.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: More wacky grouping
Date: Thu, 03 Apr 2003 21:58:13 -0800
Message-ID: <3E8D1EF5.8030201@joeconway.com> (raw)
In-Reply-To: <002601c2fa41$3a88d760$4500a8c0@theplague>
References: <002601c2fa41$3a88d760$4500a8c0@theplague>
James Taylor wrote:
> So, say I wanted to do a sum function, it would end up with something
> like:
>
> Company | Sum
> -------------------
> Globochem | 1130.84
> Toxichem | 1239.47
>
Same crosstab function mentioned the other day:
select company, sum(acct_bal) as "sum" from (select name, company,
acct_bal from crosstab('select id_customer, id_datatype, content from
mytable order by 1','select distinct id_datatype from mytable') as
(id_customer int, name text, company text, acct_bal numeric)) as ss
group by company;
company | sum
-----------+---------
Toxichem | 1239.47
Globochem | 1130.84
(2 rows)
HTH,
Joe
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: mail@joeconway.com, jtx@hatesville.com
Subject: Re: More wacky grouping
In-Reply-To: <3E8D1EF5.8030201@joeconway.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