Groups | Blog | Home
all groups > sql server (alternate) > october 2003 >

sql server (alternate) : displaying extra characters with COLUMN-defined number format?


Alex
10/7/2003 8:58:56 AM
Here's a tricky SQL question that has definitely driven me to the end of
my rope. I'm using Oracle 9i and I need to perform some simple
multiplication on a field and then display it with a percent sign using
the COLUMN command. Here's the code thus far:

COLUMN price format 9,999.99 HEADING 'Charged%'
SELECT pricecharged * .231 as price
FROM VT_examdetail

The output from this reads:

Charged%
---------
23.10
34.65
34.65
....


The kicker here is that I need to add a percent sign to the right of the
output, so that it reads:


Charged%
---------
23.10%
34.65%
34.65%
....

I thought I could do this by just adding "|| ('%')" into the SELECT
statement, but when I do this the decimal position defined in the COLUMN
command is lost. Does anyone know another way around this?

Thanks,
Alex

manrajshekar NO[at]SPAM yahoo.com
10/7/2003 4:14:51 PM
Hi,

You could do this:

select cast( charged as varchar(10)) + '%' from orders

Regards,
Lyndon Hills
10/7/2003 7:10:52 PM
[quoted text, click to view]
Greg D. Moore (Strider)
10/8/2003 2:33:46 PM

[quoted text, click to view]

Couple of comments, this is a ms-sqlserver forum, not Oracle.

However, the other answers should work.

But, I'd say you're going about this the wrong way. Formatting should be
done at an entirely different level than the DB.


[quoted text, click to view]

AddThis Social Bookmark Button