Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to display default value if sql not return any row.

Vemula MuniSep 13 2019 — edited Sep 20 2019

Hi All,

Below is my query. In that i will pass the emplid and comparison date dynamically.

For that emplid and date combination, if project id is present then i need to fetch that project id. if project id is not present then i need to display some default value.

  1. When query returns project id i want to exclude the default value, if query not return any row then i need to get some default value.

Note : Query may return one or more projectid for one employee.

SELECT B.PROJECT_ID FROM PS_CTSRM_ASGNSR_VW B , PS_RS_ASSGN_DETAIL C WHERE B.ASSIGNMENT_ID = C.ASSIGNMENT_ID AND

B.EMPLID = '155114'

AND B.ASSIGN_STS IN ('A','C') AND TO_DATE('2019-08-01','YYYY-MM-DD') BETWEEN C.START_DT AND C.END_DT

In below example my query returns value,so no need the default value in this case.

pastedImage_0.png

in below example query not return any row , so i want to display some default value.

pastedImage_1.png

This post has been answered by L. Fernigrini on Sep 13 2019
Jump to Answer

Comments

Post Details

Added on Sep 13 2019
3 comments
8,395 views