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
What is difference between isnull and coalesce?
What is the maximum size of varchar data type in db2?
File not opened because library is *PROD and debug is UPDPROD(*NO). ? what may be the reason? how to solve it..?
What is db2 connect?
How can tablespace be moved to another dasd volume that is allocated for that tablespace?
How can we read records for specific member in CL? AND rpg?
Name the lockable units in DB2?
What is precompiler in db2?
What is the usage of open cursor command?
Explain about dbrm.
What is the connection string to connect to the DB2 Database ?
What are the two types of logging in the db2 database? Explain them.
Can one database have multiple instances?
Explain in brief how does db2 determine what lock-size to use?
Define db2 and its databases?