Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formatting as percent

Status
Not open for further replies.

riluve

Technical User
Mar 11, 2005
78
US
I have a result in a column that comes as a number e.g. 0.1 - I would like to display this number (during a query) in a percent format e.g.

Current Field output:
0.1
1.0
0.34

The preferred output:
10%
100%
34%

Thnx for any guidance.
 
Multiply by 100, convert to int, convert to varchar, append '%'.

------
Theory: everybody knows everything, nothing works
Practice: everything works, nobody knows why

[banghead]
 

Dude! that looks like exactly what I need:

convert(varchar, convert(int,(field * 100))) + '%' + '%'

Thnx :-(

But when I put in my query and replace field - I get a syntax error.

:-(

I am using MySQL 3.23.58

The Documentation I find on CONVERT though has a slightly different syntax. I don't find an example of CONVERT used to change data types - only encoding types:

CONVERT(expr USING transcoding_name)

.
 
OH No - lol I am iin the wrong forum - my bad!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top