Solved

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

Posted on 2012-03-13
2
424 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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
SQL 2012 Syntax Error 5 24
SQL Script to find duplicates 16 19
Database Containment - Benefits 6 25
backups - Strategies 1 13
SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

758 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now