I have two tables called order and public holiday as following:
Order Table:
OrderId OrderDate
---------------------------
1 10 Mar 2017
You can use an outer join like this:
SELECT OrderId,
OrderDate,
case when holidaydate is not null then 'Public holiday'
else to_char(OrderDate, 'Day') end as DAY
from orders
left outer join holidays
on OrderDate = holiday_date ;
If the dates match holidaydate
is not null so the CASE clause displays your desired string otherwise it displays the day of the orderdate
.
order
is a reserved word. Presumably your real table has a different name, to avoid the ora-00903
error. I have used orders
in my example, so you will need to edit my code to match your table name(s).