SELECT DISTINCT CASE
WHEN esc.x1 = Substr(inp.y, 0, 3)
AND esc.x2 = Substr(inp.y, 4, 2)THEN esc.cc
WHEN esc.mcc = Substr(inp.y, 0, 3)
AND esc.mnc = Substr(inp.y, 4, 3)THEN esc.cc
END
FROM xxx inp,
yyy esc
WHERE CASE
WHEN esc.x1 IN( Substr(inp.y, 0, 3) )
AND esc.x2 IN( Substr(inp.y, 4, 2) )THEN esc.cc
WHEN esc.x1 IN( Substr(inp.y, 0, 3) )
AND esc.x2 IN( Substr(inp.y, 4, 3) )THEN esc.cc
END IS NOT NULL
Now the query is returning more than one row because it is satisfying both the case statement. what i want is if the case statement is NULL then only it should go for second one.Otherwise only the output of first case should be the output.Pls help me to modify the query accordingly.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
SELECT DISTINCT
CASE
WHEN esc.x1 IN (SUBSTR (inp.y, 0, 3))
AND esc.x2 IN (SUBSTR (inp.y, 4, 2), SUBSTR (inp.y, 4, 3))
THEN
esc.cc
ELSE NULL
END
FROM xxx inp, yyy esc
WHERE
CASE
WHEN esc.x1 IN (SUBSTR (inp.y, 0, 3))
AND esc.x2 IN (SUBSTR (inp.y, 4, 2), SUBSTR (inp.y, 4, 3))
THEN
esc.cc
ELSE NULL
END
IS NOT NULL;
"The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
SELECT DISTINCT CASE
WHEN esc.x1 = Substr(inp.y, 0, 3)
AND esc.x2 = Substr(inp.y, 4, 2)THEN esc.cc
WHEN esc.mcc = Substr(inp.y, 0, 3)
AND esc.mnc = Substr(inp.y, 4, 3)THEN esc.cc
END
FROM xxx inp,
yyy esc
WHERE CASE
WHEN esc.x1 IN( Substr(inp.y, 0, 3) )
AND esc.x2 IN( Substr(inp.y, 4, 2) )THEN esc.cc
WHEN esc.x1 IN( Substr(inp.y, 0, 3) )
AND esc.x2 IN( Substr(inp.y, 4, 3) )THEN esc.cc
END IS NOT NULL
Now the query is returning more than one row because it is satisfying both the case statement. what i want is if the case statement is NULL then only it should go for second one.Otherwise only the output of first case should be the output.Pls help me to modify the query accordingly.
Thnx in advance.
Please clarify, I am only seeing ONE case statement with two "WHEN" conditions.
What do you mean by: "what i want is if the case statement is NULL then only it should go for second one." which is the first and which is the second?
"The person who says it cannot be done should not interrupt the person doing it." --Chinese Proverb
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.
Bookmarks