Crosstab Confusion - Mailing list pgsql-sql

From Adam Sherman
Subject Crosstab Confusion
Date
Msg-id C5C50165-6162-460C-8E13-A0A76D0B726B@sherman.ca
Whole thread Raw
Responses Re: Crosstab Confusion  (Lee Hachadoorian <lee.hachadoorian@gmail.com>)
List pgsql-sql
I'm really trying to understand how the tablefunc crosstab function works, to no avail.

I have a table that looks like this:

customer_id integer
date timestamp with time zone
amount numeric(10,4)

There are rows in this table every-time a customer gets charged an amount, which is multiple times per day.

I would like to get a result like this:

customer_id,day1,day2,day3,(…)
1,400.00,500.01,123.00,(…)

So, one row for each customer id and a column for every day in the current month. Anyone used crosstab for something
likethis? 

Thanks for your help,

A.


--
www.sherman.ca / +1-613-797-6819 / +1-646-233-3400

"When the burning husks of your startups warm the last of your bones, remember I told you so." - Zed



pgsql-sql by date:

Previous
From: Yeb Havinga
Date:
Subject: Re: selecting rows tagged with "a" but not "b"
Next
From: Lee Hachadoorian
Date:
Subject: Re: Crosstab Confusion