can anyone help me with fine tuning this query

SELECT t1.COL1
FROM ABC t1, XYZ t2, MNO t3
WHERE t1.COL1 = t2.COL1
AND t1.COL1 = t3.COL1
AND t1.COL2 = t2.COL2
AND t1.COL2 = t3.COL2
AND t1.COUNTRY_C='USA'
AND t2.TYPE_ID= 'WEB'
AND t3.USER_ID ='sssss'
AND t1.COL2='000'
AND t2.FIN_ID = '12'
AND t1.COL1 not in (
SELECT t1.COL1
FROM ABC t1, XYZ t2, MNO t3
WHERE t1.COL1 = t2.COL1
AND t1.COL1 = t3.COL1
AND t1.COL2 = t2.COL2
AND t1.COL2 = t3.COL2
AND t1.COUNTRY_C='USA'
AND t2.TYPE_ID= 'WEB'
AND t3.USER_ID ='sssss'
AND t1.COL2='000'
AND t2.FIN_ID = '13')
ORDER BY t1.COL1

Comments

  • : SELECT t1.COL1
    : FROM ABC t1, XYZ t2, MNO t3
    : WHERE t1.COL1 = t2.COL1
    : AND t1.COL1 = t3.COL1
    : AND t1.COL2 = t2.COL2
    : AND t1.COL2 = t3.COL2
    : AND t1.COUNTRY_C='USA'
    : AND t2.TYPE_ID= 'WEB'
    : AND t3.USER_ID ='sssss'
    : AND t1.COL2='000'
    : AND t2.FIN_ID = '12'
    : AND t1.COL1 not in (
    : SELECT t1.COL1
    : FROM ABC t1, XYZ t2, MNO t3
    : WHERE t1.COL1 = t2.COL1
    : AND t1.COL1 = t3.COL1
    : AND t1.COL2 = t2.COL2
    : AND t1.COL2 = t3.COL2
    : AND t1.COUNTRY_C='USA'
    : AND t2.TYPE_ID= 'WEB'
    : AND t3.USER_ID ='sssss'
    : AND t1.COL2='000'
    : AND t2.FIN_ID = '13')
    : ORDER BY t1.COL1
    :
    :


    By stating FIN_ID = 12 you will not retrieve any COL1 that FIN_ID is related to unless FIN_ID 12 and FIN_ID 13 can be related to the same COL1's. In that case try using MINUS. The FIN_ID 12 query results minus the FIN_ID 13 query results.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion