Oracle SQL, PLSQL, APEX How To's by Dr. S. Raghunathan - HTML preview

PLEASE NOTE: This is an HTML preview only and some elements such as links or page numbers may be incorrect.
Download the book in PDF, ePub, Kindle for a complete version.

 

 

14.05      How to use decode( )

function

 

Syntax: select report-type,

 

decode(report-type,'BS','Balance Sheet','Profit and

Loss') as report-Desc from raak-ledger-master ; Result:

 

REPORT-TYPE       REPORT-DESC

 

- - - - - - - - - - - -        - - - - - - - - - - - - BS                             Balance Sheet

PL                            Profit and Loss

 

14.06  How to use case statement

 

The same function result can be achieved through case since it is simpler and understand and wordier commas are removed ,

Case ( column-name, when ,    then,    when,   then, else   end )

Syntax: select report-type, case report-type when 'BS' then 'Balance Sheet' else'Profit and Loss' end  as

report-Desc from raak-ledger-master ; REPORT-TYPE       REPORT-DESC

- - - - - - - - - - - -        - - - - - - - - - - - -