Sunday, May 31, 2015

Dynmic Sorting Based SQL Query

select
 employee_number EMPNO,
 full_name NAME
from per_people_f
order by
  decode(:P2_ORDER_BY,'EMPNO',empno,null)
, decode(:P2_ORDER_BY,'NAME',name,null)
, decode(:P2_ORDER_BY,'EMPNO,FULL_NAME',empno,
 name,null)

2 comments: