pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Joe Conway <mail@joeconway.com>
To: Caleb Simonyi-Gindele <csg@bordervet.ca>
Cc: pgsql-sql@postgresql.org
Subject: Re: contrib/tablefunc crosstab
Date: Thu, 05 Aug 2004 11:18:51 -0700
Message-ID: <41127A0B.5030807@joeconway.com> (raw)
In-Reply-To: <000001c47b10$97178250$c201a8c0@borderveygqj37>
References: <000001c47b10$97178250$c201a8c0@borderveygqj37>

Caleb Simonyi-Gindele wrote:
> My problem is that the rows are populated from right to left irrespective of
> the column. So the $561.99 in vet1 actually belongs to vet2. There are never
> any blank cells in the middle or start of a row - they always come at the
> end. How do I get the amount for that date into the appropriate column?

You either need to be sure there are no "gaps" in your source rows 
(provide one row for every category for each group, e.g. by doing an 
outer join) or use the hashed version of the function. Search the README 
for:

crosstab(text source_sql, text category_sql)

That is the hashed version that will do what you're looking for.

HTH,

Joe



view thread (2+ messages)

Message-ID: <41127A0B.5030807@joeconway.com>
Permalink:  ../41127A0B.5030807@joeconway.com/
Also on:    postgresql.org/message-id/41127A0B.5030807@joeconway.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: mail@joeconway.com, csg@bordervet.ca
  Subject: Re: contrib/tablefunc crosstab
  In-Reply-To: <41127A0B.5030807@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