Solved

Transact SQL statement to display a decimal value to 1 decimal place

Posted on 2012-03-13
2
427 Views
Last Modified: 2012-03-13
I have a column named WinPct defined as decimal(8.0)

The following statement returns WinPct as a hole number:

SELECT WinPct FROM HMHoleRankings  ...

17
16
16
16
15
15

Stored values are 17.2, 16.5, 16.3, 16.0 etc.

What is the syntax or displaying the stored values?

Thanks,
0
Comment
Question by:Dovberman
2 Comments
 
LVL 37

Accepted Solution

by:
ValentinoV earned 500 total points
ID: 37714795
Try CONVERT(decimal(8,1), WinPCT)

But in your case I think you'll always get ".0" because the zero in your data type definition indicates that there are no digits to the right of the decimal separator.

If your column is supposed to store numbers with up to one digit after the decimal separator, then the definition should become decimal(8,1).

See also: http://msdn.microsoft.com/en-us/library/ms187746.aspx
0
 

Author Closing Comment

by:Dovberman
ID: 37714909
Perfect. Thank you.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question