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


Please Help Members By Posting Answers For Below Questions

File not opened because library is *PROD and debug is UPDPROD(*NO). ? what may be the reason? how to solve it..?

2375


What is ibm db2 database?

530


Explain how can you do the explain of a dynamic sql statement?

649


How connect db2 database to datastage?

759


Define check constraint.

642






What db2 400?

673


Which components manage deadlocks in db2?

606


How to execute stored procedures?

618


What is package in db2 mainframe?

555


What is the use of runstats in db2?

573


Discuss about db2 bind?

667


What is dbrm in db2 database?

584


What is commit in db2?

591


Explain about dbrm.

605


What does reorg do in db2?

574