Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Data Bases > Oracle Miscellaneous > Re: query
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 7 of 18 Topic 6879 of 7280
Post > Topic >>

Re: query

by Ed Prochak <edprochak@[EMAIL PROTECTED] > May 8, 2008 at 06:00 AM

On May 8, 7:33 am, "ame...@[EMAIL PROTECTED]
" <ame...@[EMAIL PROTECTED]
> wrote:
> On May 8, 6:32 am, gazzag <gar...@[EMAIL PROTECTED]
> wrote:
>
>
>
> > On 7 May, 18:50, "ame...@[EMAIL PROTECTED]
" <ame...@[EMAIL PROTECTED]
> wrote:
>
> > > Thanks for the feedback Mark.  Say I have this data:
>
> > > Customer Id      Action Date     Status
> > > ---------------------------------------
> > > 12345678        12/01/2005       Active
> > > 12345678        03/01/2005       Inactive
> > > 12345678        01/01/2005       Active
> > > 24568123        11/15/2005       Inactive
> > > 33445566        03/01/2006       Active
> > > 32548798        02/28/2005       Active
> > > 77777733        02/15/2005       Inactive
> > > 77777733        02/01/2005       Active
>
> > > Now, basically I want to ignore row# 5 as it falls outside my range.
> > > I also want to ignore row 4 as his status is inactive.
> > > I want to include rows 6 as he is active, and row 1, as his MAX date
> > > shows him active.
>
> > > That is the key, that his MAX date still shows him active.
> > > Row #7 will be ignored because his MAX date shows him as
inactive....
>
> > > Does that make more sense?  And, we are on 10g R2....
>
> > > Thanks again!
>
> > > John
>
> > As Mark said, post the relevant CREATE TABLE script, together with an
> > INSERT script to populate the table and someone will be more inclined
> > to help with your query.
>
> > HTH
>
> > -g
>
> I do not understand why the CREATE table will help here.  The three
> columns of interest are above.  If you see the CREATE statement, how
> does that help with the query?  Those are the only three columns which
> are related here......
>
> Any why the INSERT also?
>
> John

It would help us help you if we could reproduce your problem without
having to write everything including the test data ourselves.

I tried yesterday but TOAD crashed on me. The solution I was checking
was essentially becoming a series of nested queries.
First is one to find the max date for each customer (simple group by).
Using that as a view, find the Active customers (join view and base
table on customer id and where base table status=Active)

Get that written and I think you will be just about there. In the
final query, I'll bet you do not need the DISTINCT.

Ed
(that is a clue I often see when people show me queries that do not
work. When I see DISTINCT, Most often it means that not all the
conditions were included.)
 




 18 Posts in Topic:
query
"amerar@[EMAIL PROTE  2008-05-06 13:54:19 
Re: query
Mark D Powell <Mark.Po  2008-05-07 09:44:54 
Re: query
"amerar@[EMAIL PROTE  2008-05-07 10:50:02 
Re: query
Urs Metzger <urs@[EMAI  2008-05-08 20:45:15 
Re: query
gazzag <gareth@[EMAIL   2008-05-08 04:32:06 
Re: query
"amerar@[EMAIL PROTE  2008-05-08 05:33:56 
Re: query
Ed Prochak <edprochak@  2008-05-08 06:00:03 
Re: query
gazzag <gareth@[EMAIL   2008-05-08 06:21:13 
Re: query
"amerar@[EMAIL PROTE  2008-05-08 07:40:19 
Re: query
gazzag <gareth@[EMAIL   2008-05-08 08:06:11 
Re: query
"amerar@[EMAIL PROTE  2008-05-08 09:37:01 
Re: query
"amerar@[EMAIL PROTE  2008-05-08 11:55:55 
Re: query
Urs Metzger <urs@[EMAI  2008-05-08 21:40:25 
Re: query
Ed Prochak <edprochak@  2008-05-09 05:40:13 
Re: query
"amerar@[EMAIL PROTE  2008-05-12 05:56:52 
Re: query
"amerar@[EMAIL PROTE  2008-05-12 05:59:18 
Re: query
Urs Metzger <urs@[EMAI  2008-05-12 16:57:59 
Re: query
"amerar@[EMAIL PROTE  2008-05-12 06:30:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Wed Dec 3 0:36:17 CST 2008.