Hi i need to write a query on the following requirement.
SELECT COMM_TEXT
INTO :WS_MIKM_COMM_TEXT
FROM MPIPROD.MIKMV01
WHERE ACCOUNT_NO = :WFD_ACCOUNT_NO
AND (SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT
AND SUBSTR(COMM_TEXT,47,14) = :WS_DENY_DESC)
OR (SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT)
The above query is to be modified. The requirement is if
both the fields are equal then that has to be given
priority. In the above query if it satisfies any one it
comes out without checking if both being equal is possible.
Answer Posted / satish
SELECT COMM_TEXT
INTO :WS_MIKM_COMM_TEXT
FROM MPIPROD.MIKMV01
WHERE (CASE WHEN (SUBSTR(COMM_TEXT,1,39 = :WS_COMMENT_TEXT)
AND SUBSTR(COMM_TEXT,47,14) = :WS_DENY_DESC)) THEN 1
ELSE
(SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT) THEN 2
END) IN (1,2)
AND ACCOUNT_NO = :WFD_ACCOUNT_NO
Tell me if i am wrong??
ACCOUNT_NO = :WFD_ACCOUNT_NO
AND CASE
OR (SUBSTR(COMM_TEXT,1,39) = :WS_COMMENT_TEXT)
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How do you simulate the explain of an embedded sql statement in spufi/qmf?
Define declaration generator (dclgen).
How is the value function used?
While unloading huge amount of data from table. Suddenly job failed some error. Imagine 1M data unloading, In that 90% data unloaded only 10% left, So if want to unload the rest 10% what needs to be done? Whether do i need to start from top or anything ?
What is difference between isnull and coalesce?
Which are the db2 tools to protect integrity of the database?
If the cursor is kept open followed the issuing of commit, what is the procedure to leave the cursor that way?
What is phantom read in db2?
What is rebind in db2?
What are the bind parameters ibm db2?
what is utility for parm lib
Is db2 a database?
DB2 can implement a join in three ways using a merge join, a nested join or a hybrid join. Explain the differences?
How many databases can be created inside an instance in db2 ?
How do you concatenate the firstname and lastname from emp table to give a complete name?