| From: | Jeff Eckermann <jeff_eckermann(at)yahoo(dot)com> |
|---|---|
| To: | Vincent Stoessel <vincent(at)xaymaca(dot)com>, pgsql-general(at)postgresql(dot)org |
| Subject: | Re: simple yet complex join |
| Date: | 2002-05-17 14:04:09 |
| Message-ID: | 20020517140409.26051.qmail@web20801.mail.yahoo.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
I think what you are looking for is a "pivot table"?
This is not easy using SQL, but workarounds have been
discussed several times in the past. I suggest you
search the archives for "pivot table", and you will
find plenty of references.
--- Vincent Stoessel <vincent(at)xaymaca(dot)com> wrote:
> Hello All,
> I've been reading the archives, the manual and my
> sql books.
> lack of sleep is making what seems easy very hard to
> figure out
> right now.
>
> what kind of join do I have to do in order to
> combine 3 tables of
> similiar information. For example 3 months' worth of
> payments from
> customers:
>
>
> jan_pay
>
>
> tom 25
> ron 30
> jim 0
>
>
> feb_pay
>
> tom 25
> ron 20
> jim 10
>
>
> march_pay
>
> tom 25
> ron 30
> jim 5
> pat 40
>
>
>
> I want a result that looks like this :
>
>
> tom 25 25 25
> ron 30 20 30
> jim 0 10 5
> pat 0 0 40
>
>
>
> I've tried so many kinds of strage joins that I am
> ashamed to post them
> here. Can someone please light the candle?
> Thanks in advance.
>
>
> --
> Vincent Stoessel
> Linux Systems Developer
> vincent xaymaca.com
>
>
> ---------------------------(end of
> broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
__________________________________________________
Do You Yahoo!?
LAUNCH - Your Yahoo! Music Experience
http://launch.yahoo.com
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Vincent Stoessel | 2002-05-17 14:25:42 | Re: simple yet complex join |
| Previous Message | Wm. G. Urquhart | 2002-05-17 11:54:42 | What am I doing wrong! |