Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Sql Query Help -- Aggregating Rows

Sql Query Help -- Aggregating Rows

From: <linux.hacker_at_gmail.com>
Date: Wed, 24 Oct 2007 08:13:54 -0700
Message-ID: <1193238834.210076.165290@v29g2000prd.googlegroups.com>


I'm having trouble figure out how to do this and thought that if I just asked people could show me some best practices and hopefully point me to some additional reading material. I've done a bit of sql but oracle is new to me (we are using oracle 9.? in case it matters)

Anyways, after joining some tables and ignoring columns I don't care about I have a table that looks like:
PurchaseDate PurchaserID PurchasersCatagory

What they want to do is look at purchases in a three week span this year and last year and get a count by purchasers category for 2006 (excluding those who also bought in 2007), 2007 (excluding...), both years

For example:

PurchaseDate PurchaserID PurchaseCatagory

2006                     1                       x
2007                     1                       x
2006                     2                       x
2006                     3                       y
2007                     4                        y
2007                    5                         z

Then they want
PurchaseCatagory 2006 2007 Both

x                               1        0      1
y                               1        1      0
z                               0         1     0

Thanks,
Bill Received on Wed Oct 24 2007 - 10:13:54 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US