Re: Ordinal Function

From: Mark D Powell <Mark.Powell_at_eds.com>
Date: 22 Jul 2004 08:32:08 -0700
Message-ID: <2687bb95.0407220732.a2b7b_at_posting.google.com>


Mark.Powell_at_eds.com (Mark D Powell) wrote in message news:<2687bb95.0407210726.2e13c8ec_at_posting.google.com>...
> Terry Coccoli <request_at_ifneeded.com> wrote in message news:<gseLc.20093110$Id.3323112_at_news.easynews.com>...
> > Has anyone created a user function to return the ordinal position based
> > on numeric input?
> >
> > In other words, f(1) returns 'st', f(2) returns 'nd', f(3) returns
> > 'rd', etc.
>
> Terry, Ordinal position of what? A varchar2 array? The ASCII value?
>
> -- Mark D Powell --

No sooner than I hit post did I realsize that you wanted first, second, third as in 1st, 2nd, 3rd, etc..., but I use google to access the newsgroup so I had to wait for the index to be updated to show my post to add on and by afternoon I had work to do.

You can build a function using the following:

select to_char(trunc(sysdate,'MM') + rownum - 1,'fm DDTH'), rownum from dba_objects
where rownum < 32
order by 2

Which will produce something like
 TO_CH ROWNUM
----- ----------

 1ST           1
 2ND           2
 3RD           3
 4TH           4
 5TH           5
 6TH           6
 7TH           7
 8TH           8
 9TH           9
 10TH         10
 11TH         11
 12TH         12
 13TH         13
 14TH         14

...

HTH -- Mark D Powell -- Received on Thu Jul 22 2004 - 17:32:08 CEST

Original text of this message