Case statement in Order by section?
From: Rich <richmarin_at_earthlink.net>
Date: Thu, 24 Jul 2008 06:03:59 -0700 (PDT)
Message-ID: <e973c2e4-0343-422a-b918-3aacb62d4611@d77g2000hsb.googlegroups.com>
End;
Date: Thu, 24 Jul 2008 06:03:59 -0700 (PDT)
Message-ID: <e973c2e4-0343-422a-b918-3aacb62d4611@d77g2000hsb.googlegroups.com>
I am usint 10g.
I know that you can put a decode in the order by section. But I tried to see if it is possible to put a case statement in the order by section. My little experiment did not work.
Has anyone in this forum successfully put a case statement in the order by section? If so, how did you do it. Below is a sample of what I tried to do.
CREATE OR REPLACE PROCEDURE TestOrderBy
(
User_Choice IN VARCHAR, TestCur IN OUT Test_OrderBy.TEstCur )IS
Begin
Open TestCur For
select object_name, User_Choice
from all_objects
Order by
Case
When User_Choice = 'A' Then object_name Else Object_Name desc
End;
END TestOrderBy; Received on Thu Jul 24 2008 - 08:03:59 CDT