Need help to Optimize this query [message #335241] |
Mon, 21 July 2008 10:19 |
srajan
Messages: 1 Registered: July 2008
|
Junior Member |
|
|
SELECT DISC.NAME,DLINES2.ENTITY_ID,DLINES2.ENTITY_VALUE
FROM
SO_DISCOUNT_LINES DLINES,SO_DISCOUNT_LINES DLINES2,SO_DISCOUNTS DISC,
SO_DISCOUNT_CUSTOMERS DCUST WHERE DISC.DISCOUNT_ID != :b1 AND
DISC.PRICE_LIST_ID = :b2 AND DCUST.DISCOUNT_ID = DISC.DISCOUNT_ID AND
DCUST.CUSTOMER_ID = :b3 AND NVL(:b4,1) = NVL(DCUST.SITE_USE_ID,1) AND
DLINES2.DISCOUNT_ID (+) = DISC.DISCOUNT_ID AND DLINES.DISCOUNT_ID = :b5
AND NVL(DLINES2.ENTITY_ID,-1) = NVL(DLINES.ENTITY_ID,-1) AND
NVL(DLINES2.ENTITY_VALUE,'') = NVL(DLINES.ENTITY_VALUE,'') AND
LEAST(NVL(:b6,TO_DATE('31-12-2900','DD-MM-YYYY')),NVL(:b7,
TO_DATE('31-12-2900','DD-MM-YYYY')),NVL(DLINES.END_DATE_ACTIVE,
TO_DATE('31-12-2900','DD-MM-YYYY'))) >= GREATEST(NVL(DISC.START_DATE_ACTIVE,
SYSDATE),NVL(DCUST.START_DATE_ACTIVE,SYSDATE),NVL(DLINES2.START_DATE_ACTIVE,
SYSDATE)) AND GREATEST(NVL(:b8,SYSDATE),NVL(:b9,SYSDATE),
NVL(DLINES.START_DATE_ACTIVE,SYSDATE)) <= LEAST(NVL(DISC.END_DATE_ACTIVE,
TO_DATE('31-12-2900','DD-MM-YYYY')),NVL(DCUST.END_DATE_ACTIVE,
TO_DATE('31-12-2900','DD-MM-YYYY')),NVL(DLINES2.END_DATE_ACTIVE,
TO_DATE('31-12-2900','DD-MM-YYYY'))) AND ROWNUM < 2
|
|
|
|
|