Grouped data on detail record [message #617574] |
Tue, 01 July 2014 18:16 |
|
RM33
Messages: 11 Registered: December 2013 Location: New York City
|
Junior Member |
|
|
I am using 10g.
Imagine this table:
Customer_ID, Purchase, Purchased_Date.
I need detail information. Select Customer_ID, Puchase, Purchase_Date From Customer_Table.
Then I need the average purchase from the last 6 months. Then I need to subtract Purchase from Avg(Purchase) So the SQL might look something like this:
Select Customer_ID, Puchase, Purchase - Avg(Purchase) as Activity, Purchase_Date From Customer_Table
How do I do this?
|
|
|
|
|
Re: Grouped data on detail record [message #617587 is a reply to message #617574] |
Wed, 02 July 2014 01:47 |
John Watson
Messages: 8931 Registered: January 2010 Location: Global Village
|
Senior Member |
|
|
If you have what appears to be a complicated problem, build up to it slowly. In this case, I would begin with query that selects all the rows for the last six months. Then a query that averages the price of those rows.
|
|
|