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: Oracle SQL problem... Newbie question

Re: Oracle SQL problem... Newbie question

From: Edorta <edortta_at_yahoo.es>
Date: Mon, 25 Oct 1999 17:08:35 +0200
Message-ID: <38147273.DA4F67FE@yahoo.es>


You could try the following:

select decode(awd.item_type, 60, 0, 30, 1, 45, 2, 90, 3, 46, 4, 5), ... from ...
where ...
order by 1;

You'll have one more field and the query will be slower because it will probably not use indexes, but it'll work.

Good luck,
Edorta

Unmesh wrote:

> Hi all,
> I have a problem with the 'order by' clause in SQL. I have a query like
>
> select
> AWD.ITEM_TYPE,
> AWD.EMPLID,
> AWD.INSTITUTION
> FROM PS_STDNT_AWARDS AWD,
> PS_ITEM_TYPE_FA ITF
> WHERE AWD.EMPLID = 'XXXXX'
> AND AWD.INSTITUTION = 'YYYYY'
> AND AWD.AID_YEAR = '2000'
> AND ((AWD.AWARD_PERIOD = 'A') OR (AWD.AWARD_PERIOD = 'B'))
> AND ((AWD.AWARD_STATUS = 'A') OR (AWD.AWARD_STATUS = 'O'))
> AND ITF.PRINT_LTR_OPTION <> 'N'
> AND ITF.SETID = AWD.SETID
> AND ITF.AID_YEAR = '2000'
> AND ITF.ITEM_TYPE = AWD.ITEM_TYPE
> and itf.item_type in ('60', '30', '45', '90', '46')
> AND ITF.EFFDT = (SELECT MAX(EFFDT)
> FROM PS_ITEM_TYPE_FA ITF1
> WHERE ITF1.SETID = ITF.SETID
> AND ITF1.AID_YEAR = ITF.AID_YEAR
> AND ITF1.ITEM_TYPE = ITF.ITEM_TYPE
> AND ITF1.EFF_STATUS = 'A'
> AND ITF1.EFFDT <= sysdate)
> ORDER BY ITF.ITEM_TYPE
>
> where I want the output to come in a particular order of item types.
> Like
> 60, 30, 45, 90, 46.
>
> i.e. I want to produce the output according to a particular order in a
> list of values. Which is the way to do this? Any feedback is
> appreciated.
>
> Thanks,
> Unmesh
Received on Mon Oct 25 1999 - 10:08:35 CDT

Original text of this message

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