Re: More wacky grouping

From: Joe Conway <mail(at)joeconway(dot)com>
To: James Taylor <jtx(at)hatesville(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: More wacky grouping
Date: 2003-04-04 05:58:13
Message-ID: 3E8D1EF5.8030201@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Manfred Koizar 2003-04-04 07:20:48 Re: More wacky grouping
Previous Message Roberto Mello 2003-04-04 02:09:37 Re: pesky plpgsql