First of all, start with to_char . to_char(SYSDATE,'Day') will give you the day of the week that it is today. to_char allows to_char to convert a date (in this case, today's date since you specified sysdate ) to a string of a specific format. Take a look here at some other examples of date formats you can use:
http://www.techonthenet.com/oracle/functions/to_char.php
trim removes leading and trailing spaces.
Now for decode . You can think of decode as an if else statement. Take a look at:
http://www.techonthenet.com/oracle/functions/decode.php
In your specific example, you can read this statement as: if today Monday returns 3 else return 1.
decode also allows you to do something more complex:
select decode(TRIM(to_char(SYSDATE,'Day')),'Monday','3','Tuesday',5,'1') from dual
This will read: if today Monday returns 3, otherwise if today Tuesday returns 5, else return 1
source share