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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Using the TO_CHAR function in a SQL statement

Re: Using the TO_CHAR function in a SQL statement

From: Sybrand Bakker <postbus_at_sybrandb.demon.nl>
Date: Sun, 26 May 2002 23:44:00 +0200
Message-ID: <uf2m06d0fae419@corp.supernews.com>


SELECT item_id,to_char(sum(price * qoh),'0999999.99') "Inv. Value" FROM inventory
GROUP BY item_id;

I have to lookup the format mask for the currency in the documentation (SQL reference manual, chapter 'Single row functions') so I leave that as an useful exercise to you, just to avoid doc questions like this in the future. The docs are online at http://tahiti.oracle.com and http://otn.oracle.com . You'll need an instanteanous free subscription to the latter site in both cases.

Hth

--
Sybrand Bakker
Senior Oracle DBA

to reply remove '-verwijderdit' from my e-mail address


<jkutey_at_nospam.nycap.rr.com> wrote in message
news:29j2fu0df1s9fj65gvta6kp6biiehq1g2b_at_4ax.com...

> Okay, but can you write it using the TO_CHAR function?
>
>
> On Sun, 26 May 2002 20:54:46 GMT, Bricklen Anderson <bricklen_at_shaw.ca>
> wrote:
>
> >why use the to_char function? why not rewrite it as so:
> >
> >SELECT item_id,'$'||round(sum(price * qoh),2) "Inv. Value"
> >FROM inventory
> >GROUP BY item_id;
> >
> >
> >
> >jkutey_at_nospam.nycap.rr.com wrote:
> >>
> >> Here is my query:
> >>
> >> select item_id, sum(price*qoh) "Inv. Value"
> >> FROM inventory
> >> group by item_id;
> >>
> >> How would I write this query using the TO_CHAR function to format the
> >> number values using a currency format masked with two decimal places?
> >>
> >> Thanks
> >> John
>
Received on Sun May 26 2002 - 16:44:00 CDT

Original text of this message

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