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 > Help with Query
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 2 Topic 6851 of 7030
Post > Topic >>

Help with Query

by Mtek <mtek@[EMAIL PROTECTED] > Apr 22, 2008 at 01:52 PM

Hi,

Please take a look at this query:

SELECT max(action_date), customer_id
FROM email_product_hist
WHERE action = 'A'
  AND action_date BETWEEN TO_DATE('01012007','MMDDYYYY') AND
TO_DATE('03312007','MMDDYYYY')
  AND email_product_id = 'PPM'
  AND customer_id NOT IN (SELECT customer_id FROM
new_customer.customer_account)
GROUP BY customer_id;

It works.  However, we have a table, CUSTOMER, which contains the
customers email address.  It is joined to the CUSTOMER_ACCOUNT table
by the customer ID.  It is also joined to the EMAIL_PRODUCT_HIST by
customer_id.

What I am looking to do is get the email address from the CUSTOMER
table for customers who are NOT in the CUSTOMER_ACCOUNT table, and,
are IN the EMAIL_PRODUCT_HIST table that have the above criteria for
the MAX date.

CUSTOMER_ID is unique in the CUSTOMER & CUSTOMER_ACCOUNT tables.  It
is NOT unique in the EMAIL_PRODUCT_HIST table.  So, I'm looking to get
the email, for the customer who has an action of 'A' and a
email_product_id of 'PPM' for his max(action_date), and does not exist
in the CUSTOMER_ACCOUNT table.

Hope that all makes sense.  If this cannot be done, I can just write a
block of code to do it.

Thank you,

John
 




 2 Posts in Topic:
Help with Query
Mtek <mtek@[EMAIL PROT  2008-04-22 13:52:43 
Re: Help with Query
Ed Prochak <edprochak@  2008-04-23 05:56:44 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan13V112 Sat Jul 19 5:00:35 CDT 2008.