Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Altering the ORDER BY clause based on a parameter

Re: Altering the ORDER BY clause based on a parameter

From: Tonkuma <tonkuma_at_fiberbit.net>
Date: Mon, 19 Nov 2007 10:04:03 -0800 (PST)
Message-ID: <b52f8815-be43-4f40-9072-c9830c8a8263@s36g2000prg.googlegroups.com>


How about this?

SELECT date_col, name_col, desc_col, num_col   FROM mytab
 ORDER BY

       DECODE(p_order_desc, 'ASC'

,DECODE(p_order_by,1,date_col,2,name_col,3,desc_col,
4,num_col) ) ASC , DECODE(p_order_desc, 'DESC'
,DECODE(p_order_by,1,date_col,2,name_col,3,desc_col,
4,num_col) ) DESC

; Received on Mon Nov 19 2007 - 12:04:03 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US