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 > Nasty Query Her...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 4 Topic 6828 of 7037
Post > Topic >>

Nasty Query Here

by Mtek <mtek@[EMAIL PROTECTED] > Apr 9, 2008 at 10:51 AM

Hi,

I have a REAL nasty query here which I'm hoping to make smaller by
using some joins.  I got help from here before, so while I'm trying to
do it, I was hoping some others can look at it also.

Thank you,

      SELECT c.email || '|' || ca.first_name || '|' || ca.last_name ||
'|' || 'ZACKS' || '|' ||
         TO_CHAR(c.date_registered, 'mmddrr hh24:mi:ss') || '|' ||
TO_CHAR(TRUNC(SYSDATE-1),'MM-DD-YYYY') || '|' ||
         v.adid || '|' || cd.day_phone line, 'HOUSE' list_type
      FROM customer c, customer_account ca, visitor v,
subscr_email_product s, customer_address cd
      WHERE c.date_registered BETWEEN p_start_date AND p_end_date
      AND c.customer_id = ca.customer_id(+)
      AND c.customer_id = s.customer_id
      AND c.customer_id = v.customer_id
      AND c.customer_id = cd.customer_id(+)
      AND s.email_product_id = 'HL'
      AND email NOT IN (
       SELECT email
       FROM customer c, customer.subscriptions s, customer.product p,
customer_address ca, customer_account ct, visitor v
       WHERE ca.address_type_id = 1
         AND s.status = 1
         AND s.sell_rep_id IN (201, 202)
         AND p.produst_id = 1
         AND TRUNC(start_date) BETWEEN p_start_date AND p_end_date
         AND p.produst_id  = s.produst_id
         AND c.customer_id = s.customer_id
         AND c.customer_id = ca.customer_id
         AND c.customer_id = ct.customer_id
         AND c.customer_id = v.customer_id (+))
       UNION
      SELECT c.email || '|' || ca.first_name || '|' || ca.last_name ||
'|' || 'ZACKS' || '|' ||
         TO_CHAR(c.date_registered, 'mmddrr hh24:mi:ss') || '|' ||
TO_CHAR(TRUNC(SYSDATE-1),'MM-DD-YYYY') || '|' ||
         v.adid || '|' || cd.day_phone line, 'AMERITRADE' list_type
      FROM customer c, customer_account ca, visitor v,
subscr_email_product s, customer_address cd
      WHERE c.date_registered BETWEEN p_start_date AND p_end_date
      AND c.customer_id = ca.customer_id(+)
      AND c.customer_id = s.customer_id
      AND c.customer_id = v.customer_id
      AND c.customer_id = cd.customer_id(+)
      AND s.email_product_id = 'HL'
      AND email IN (
       SELECT email
       FROM customer c, customer.subscriptions s, customer.product p,
customer_address ca, customer_account ct, visitor v
       WHERE ca.address_type_id = 1
         AND s.status = 1
         AND s.sell_rep_id IN (201, 202)
         AND p.produst_id = 1
         AND TRUNC(start_date) BETWEEN p_start_date AND p_end_date
         AND p.produst_id  = s.produst_id
         AND c.customer_id = s.customer_id
         AND c.customer_id = ca.customer_id
         AND c.customer_id = ct.customer_id
         AND c.customer_id = v.customer_id (+));
 




 4 Posts in Topic:
Nasty Query Here
Mtek <mtek@[EMAIL PROT  2008-04-09 10:51:14 
Re: Nasty Query Here
Charles Hooper <hooper  2008-04-09 17:30:35 
Re: Nasty Query Here
patrick <pgovern@[EMAI  2008-04-11 10:46:54 
Re: Nasty Query Here
Mtek <mtek@[EMAIL PROT  2008-04-16 08:30:55 

Post A Reply:
  Go here to Signup

AddThis Feed Button


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

Contact
tan13V112 Thu Jul 24 2:26:48 CDT 2008.