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 to run db2 command in windows?
What is the difference between oracle and db2?
How many types of page locks can be held in db2?
What is db2? Explain.
DB2 can implement a join in three ways using a merge join, a nested join or a hybrid join. Explain the differences?
What is ibm db2 client?
Describe major components of db2?
What is netezza database?
Before you give the explain statement, what are the prerogatives?
How does db2 sample database connect?
How to get the ddl of a table in db2?
If I have a view which is a join of two or more tables, can this view be updateable?
Highlight all the advantages that are attached to a package.
Is ibm db2 open source?
What happens in bind step in a db2 program?