Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    MS SQL Server & have generously sponsored dedicated servers and web hosting to ensure a reliable and scalable dedicated hosting solution for

Round And Show To 2 Decimal Places?

Hi All,

I have a small question to ask. How to round a numeric field upto 2 decimal places, and also show it with 2 decimal places only

For example the following would return 255.88000000000
select round(255.87908765444,2)

How to get 255.88 only?

Pleas help.



View Complete Forum Thread with Replies
Sponsored Links:

Related Messages:
How Do I Round And Truncate A Float To 2 Decimal Places?
I have a float of 70.83333333343

If I do this

SET @Output=ROUND(@Output, 2, 1) -- @Output is DECLARED as FLOAT

I get this:

I want:

How do I do that?
Thanks in advance...

View Replies !   View Related
Round Milliseconds To 2 Decimal Places In 00:02:09:6570000 Format In Sql Reporting Services?

Start End Duration

11/20/2007 12:05:57 PM

11/20/2007 12:08:06 PM


Duration =(Fields!end.Value-Fields!startdate.value) i get the output as shown above.

I need to round that output to 2 decimal places and display it as 00:02:09.65

Any ideas?

View Replies !   View Related
T-SQL ROUND(decimal, Int) Vs C# Round(Decimal, Int32)
Anybody noticed that SQL Server rounds up if the value is half waybetween two rounded values, but C#'s Decimal.Round(Decimal,Int32)rounds to nearest even number?[color=blue]>From MSDN: "When d is exactly halfway between two rounded values, the[/color]result is the rounded value that has an even digit in the far rightdecimal position. For example, when rounded to two decimals, the value2.345 becomes 2.34 and the value 2.355 becomes 2.36. This process isknown as rounding toward even, or rounding to nearest."I perform the same calculation sometimes on the web server in C# andsometimes at the database in T-SQL, but want to get the same resultfrom both calculations. Could anybody offer any strategies for dealingwith this?Thanks ~ Matt

View Replies !   View Related
2 Decimal Places On Sql AVG ()
I am trying to get my string to 2 decimal places...
Here is the code:string sumSQL = "SELECT CONVERT (float,sum(callTime)/count(callTime)) as CAVG FROM leads where agent = '" + agent + "' and " + dates.Text;
 SqlCommand sumCMD = new SqlCommand(sumSQL, conn2);
object null1 = sumCMD.ExecuteScalar();if (null1 != null)
{string avgS = sumCMD.ExecuteScalar().ToString();Response.Write(avgS + "<br>" + "</td></tr><tr>");
Any Help appreciated...

View Replies !   View Related
Decimal Places
I have many columns of data. They are all using the money datatype. When Ienter a value into a column such as 32.00, it only shows up as 32. Whenoutputted to an ASP page using a query it also only displays 32. If thedata is 32.33, then the display is 32.33. How do I get it to display 32.00?Thanks!DarrenMCP

View Replies !   View Related
Decimal Places
How do i get these decimal working?

cast(2/5 as decimal(5,2))
,cast(5/2 as decimal (4,2))

thank you

View Replies !   View Related
Decimal Places
is there a way with a float datatype to choose the number of deicmal places to use

View Replies !   View Related
Decimal Places
I am running the following query and getting result 150.76000 but I am desired 150.76. How can i get it.

SELECT ROUND(150.75600,2)

But I need the following result

View Replies !   View Related
Moving Decimal 2 Places To The Right.
Hello, I have a datatable with a column of decimal numbers 0 - 1.  I want to move the decimal 2 places to the right to make the column a percent column.  I don't know how to do that.

View Replies !   View Related
Want To Get Results Without Decimal Places

The underlying table for my fact contains a Sale field whose data type is decimal.

In the cube editor, I have tried a few options (both for Data Type and Display format) but in my front-end I am still getting the results with 2 decimal places.

Can someone kindly help me how I can get the results in a rounded form so that the decimal places are not shown e.g. instead of seeing 12,345,678.98 I want the results rounded as 12,345,679.

If (and i really hope not) it boils down to using MDX in the front end then can u kindly guide me since I can only spell MDX at the moment :(

Many thanks in advance for your help.

View Replies !   View Related
Help! SMALLMONEY:Too Many Decimal Places
Hello all...

I am new to SQL 7, and am having trouble with the money and smallmoney data-types. When I pull data from these columns, it has four decimal places, and I need only two (four is screwing the perl code up). What do I do now?

All help much appreciated!

View Replies !   View Related
How Can I Always Display 2 Decimal Places?
In MS SQL Server 2000 T-SQL, how can I always display 2 decimal places?


I wish to display

25 as 25.00

43.6789 as 43.68.

Any help would be greatly appeciated.

View Replies !   View Related
Format To 2 Decimal Places?
Hi, i need to display my data in 2 decimal places but now i'm getting results after some calculation (for eg.2.336224). How can i round it off to 2.34?

View Replies !   View Related
Decimal Places In Node_Description??
There's been several good posts on using the node description of a model as the end user description for a specific cluster. My model uses a number of continuous input columns defined as currency from a fact table in the source cube. After processing, the node description has elements that look like this:

-0.5799759795 <=Interest Expense <=0.8397462488 ,

Since the source data is currency, this makes the node description look a little strange. The data type in the model is set as double. The precision impliedby the description is not what I want the model to consider. In the case above, the difference between the numbers listed is not significant.

It would be great to have a better node desciption that doesn't imply so much precision, but the bigger question is why does the cluster model turn currency types into doubles. Should I set the data type tolong in the model so that cents are ignored? I know I should probably use discrete inputs, but I don't want to have to discretize the currency values in the cube since this would require me to set up fact dimensions for each currency column in the fact table.

View Replies !   View Related
Convert Value To 2 Decimal Places?

Hello, is there a way to convert the value to just 2 decimal places, I created the report in Reporting Services and it has quite a few digits to each value. I looked at the table and found that the data type is {Float}. Is there a way to convert the values to just 2 decimal places?..Thank You.

View Replies !   View Related
Decimal Places Displayed

I'm running the following query against a SQL Server 2003 database to receive the results below:

SELECT PayPeriod AS [Pay Period], SUM(PayHours) AS [Pay Hours]
FROM EmployeePayHours
GROUP BY PayPeriod

Pay Period Pay Hours71380





A colleague of mine, however, is running the same query against the same database (using a different machine)and gets the following results.

Pay Period Pay Hours






Is there a setting somewhere that needs to be changed? Thanks.

View Replies !   View Related
Convert Variable To Only Two Decimal Places
Dim subtot As Double
Dim tax As Double
Dim tot As Double
subtot = "0.00"
Dim sql As String
sql = "SELECT items.qty, products.descrip, products.price FROM items INNER JOIN products ON items.productid = WHERE (items.orderid = " & Request.QueryString("oid") & ")"Dim objConn As New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|AllStar.mdf;Integrated Security=True;User Instance=True")
Dim cmdCustomers As New SqlCommand(sql, objConn)Dim dataReader As SqlDataReader
dataReader = cmdCustomers.ExecuteReader(CommandBehavior.CloseConnection)While dataReader.Read
subtot = subtot + (dataReader.GetValue(0) * dataReader.GetValue(2))
End While
tax = (subtot * 0.07)
tot = (subtot + tax)
Label1.Text = subtot
Label2.Text = tax
Label3.Text = tot
How to a convert the variable tax to just two decimals?
I tried label2.text = CType(tax, Double)
but that didn't work either
Thanks in advance

View Replies !   View Related
Help Withrounding Money To 2 Decimal Places?
I have a table with a money field that had previously been running calculation and storing the data into the database's money field. Since this field supports 4 decimal places, it was storing 4 decimal places worth of data. I have since cleaned up my insert routine to round everything up to two decimal places and it only inserts the rounded values. I now have to go back and update the old data with the two decimal place rule. How would I go about doing this?

15.1456 ================ 15.15
4.1328 ================== 4.13
5.16 =================== 5.16

View Replies !   View Related
Formatting Decimal Places In A Query In MS SQL
Hey - I have a quick question and know that it is probably pretty simple, but I am stumped. I have a query where I need to make a colum a number that looks like a percent with 2 significant digits:

SELECT tblNumericCovert.number1, tblNumericCovert.number2, [number1]/[number2] AS testDiv
FROM tblNumericCovert

where testDiv needs to spit out results like this ###.##

I am totally lost, if anyone can help, I would appreciate it.

View Replies !   View Related
Decimal Places For Integer Divisions
SELECT 1/2 returns 0 in transact sql instead of 0.500000

How do I get it to return 0.5000 ?

View Replies !   View Related
Fixed Decimal Places Without Rounding
What is the best way to force a 2 digit decimal place without rounding?
For example select price*UOM returns

What i want to be returned is



View Replies !   View Related
Set Up Query To Return Only 2 Decimal Places?
Hi. I have a query that returns several averages and percentages. Is there some way to set up the query so the results only go to 2 decimal places? Here is a sample of the query I am using:

$query = "SELECT COUNT(deal_id), SUM(vs), SUM(vs)/COUNT(deal_id)*100, AVG(fin) FROM sales GROUP BY salesperson";

It works great,except the results are several decimal places long, and I need it to be only 2.

Any help appreciated.

Never mind, I found it muhself....

FORMAT(AVG(fin),2) works perfectly!!

View Replies !   View Related
Money Field Decimal Places
I have a field in a database which is a datatype Money. When I run a select query the data is coming back with 4 decimal places like 100.0000 but I only want 2 decimal places like 100.00.

Anyone know how to get this?

View Replies !   View Related
Decimal Places On Money Values

I have an SQL search that is converting two values to type money. I want it to show two digits after the decimal point but am getting inconsistent results. The first value is as follows:

tblInventoryItem.itemcost as originalcost (the column is datatype money)

This displays correctly i.e. 2000.00 or 150.70 etc

The second value is this:

tblInventoryItem.itemcost + tblUpgrades.ItemCost as totalcostincupgr (both columns are datatype money)

But this displays as 2000 or 150.7

How can I get the second value to show two decimal places even when the digits are zeros?


View Replies !   View Related
Format Field With Decimal Places
Hi all,

I need to format a field to a set number of decimal places which is held as a field within the DB, and also format it as a standard number.

I have been able to set the format of the field to the decimal places field and it all works (the quantity in the row has the right number of decimal places), but i cant now format it as a number...

Heres an example:

The quantity is 1500 with 3 decimal places so it becomes 1500.000

I need to format it as a number with comma's etc such as 1,500.000

How would i go about doing this? Ive already used the format option for the decimal places and dont know how to add another format type (which in this case will be N)



View Replies !   View Related
Missing Decimal Places After Cast()-ing
Hello, The issue is to convert a number like 114270 to 114 + (270/320) = 114.84375. The decimal version is the desired result. In other words the last 3 digits of 114270 are in base 320.

Question: I cast my number as char() then use substring() to get the digits. Then I cast back to float and divide by 320. I get 0 when I do this and I'm not sure why.

Code follows:
declare @p float
set @p = (select top 1 P from [tablename] where Product = 'Z')

declare @pchar as char(6)
set @pchar = cast(@price as char(6))
declare @first3 as char(3)
declare @second3 as char(3)
set @first3 = cast(substring(@pchar, 1,3) as float(25))
set @second3 = cast(substring(@pchar, 4,6) as float(25))
select @pchar -- 114270
select @first3 -- 114
select @second3/320 -- 0

I have tried changing cast(substring(@pchar, 4,6) as float(25)) to
cast(substring(@pchar, 4,6) as decimal)
and I get the same result. Any suggestions or is there a better way altogether?

View Replies !   View Related
Not Getting An Exact Match Upto Decimal Places...

This is strange....

I am getting my source data from another system am storing the SaleAmount of each product in a field the data type of which is [decimal](12, 2).

For some products I am getting an exact match (upto 2 decimal places) as compared with my source data BUT for some other products the value before the decimal places is correct but the 2 digits after the decimal place does not match with the source data :confused:

Even if this sounds stupid, can you please guide me. Am i missing some very basic and common sense thing?

Many TIA.

View Replies !   View Related
Formatting A Float Variable To 2 Decimal Places

I am filling a temp table with various float variables and I need to format one particular column to 2 decimal places.

Does anyone know the correct syntax to do this, and should it be done before filling the temp table or when I select what I needs from the temp table?


View Replies !   View Related
Dividing Two Numbers Truncates After 4 Decimal Places
I have two fields - both defined as money.
When I divide them, SQL Server truncates the result after the 4th decimal point.
So SQL Server says: 370.45 / 3,391,517.85 = 0.0001
I want to achieve: 370.45 / 3,391,517.85 = 0.00010922837... etc.
The field the result is going into is defined as decimal(20,18)

I've tried using "cast(1stmoneyfield as decimal(20,18)) / cast(2ndmoneyfield as decimal(20,18)) as dividednumber", but SQL Server reports back errors about null values and Arithmetic overflow and terminates.

I'm at a loss as to how to solve the problem. Any suggestions please?

View Replies !   View Related
Reduce Scale Of Floats To 4 Decimal Places From 16
I am working with an off the shelf app that controls decimal places through the application. All columns underlying the apps 'numeric' fields are floats. We are writing some scripts that need to compare numbers and some of them look like the second row

KELLYJ 2.1233
DONOVM 1.6000000000000001
OLSSON 15.3750

I have tried using round and cast. My examples work like the following:

SELECT 27.719999999

SELECT CAST(ROUND(27.719999999,4) AS DECIMAL(50,4))

When I try the same against a column to update the entire table it leaves the rows like above as longer to the right of the decimal point.

Any pointers on how to get these numbers back to 4 decimals places would be much appreciated

View Replies !   View Related
Stored Procs - Limiting The Decimal Places
I have a stored proc that is inserting an order from a shopping cart into a table - but the problem is that the tax portion of it is causing a problem with CyberCash due to having more than 2 decimal places after decimal point. The part of the stored proc that is causing the problem is:

SELECT @TaxAmt = @TaxTotal * .0775

I know with VBScript I can limit the number of decimal places:


Is the same thing possible in a stored proc?

Thanks for any suggestions.

View Replies !   View Related
Only 2 Decimal Places In Field Of Type Money
I have a table in SQL 2005 with a field that has a value of type 'money'. When values are added, the field has 4 decimal places. Is there a way that I can make it only have 2 decimal places right away? Thanks!!!

View Replies !   View Related
Losing Decimal Places On Sql Svr To Sql Svr Data Flow

I have a staging table that has a float [DT_R8] column that shows 4 decimal places. When I use an OLE DB Source referencing that table to go to an OLE DB Destination referencing a table with an identical column the data gets rounded to a single decimal place. Needless to say this is really messing with the values.

I can see the Scale property in the Advanced Editor for OLE DB Destination but I cannot change it. Same for the OLE DB Source.

Oh, and if I do an insert using SQL in Management Studio I have no problem getting the 4 decimal places in. For example:

Insert into table2
(Col1, Col2)
select Col1, Col2 from table1

Moves all the data and keeps the 4 decimal places.

How do I do this without losing those decimals?


View Replies !   View Related
Format Money Or Float 2 Decimal Places
How do I format the money or float field types to 2 decimal places during a SELECT statement?

View Replies !   View Related
Adding Number Of Decimal Places During Table Design

Nice easy one (hopefully) from a newbie on SQL 2000.

I have a table HolidayTakenBooked which is populated from a stored procedure via the following statement;

TRUNCATE TABLE HolidayTakenBooked
INSERT INTO HolidayTakenBooked
SELECT * FROM #TMP_HolidayTakenBooked ORDER BY ABR_Clock_No

I am finding that for certain values in the HolidayTakenBooked table decimals are not being transferred correctly. ie. 0.5 in the TMP table appears as 1 in the HolidayTakenBooked table.

I'm pretty sure that this is down to the data definition of the table see sample field below;
[HOL_DaysTaken1] [decimal](18, 0) NULL ,

So the simple question here is how do I define decimal places when I define a new table. When designing a new table in Enterprise Manager I select decimal and the server does not allow me to change the value of 9 it defaults to.

What simple thing I am not doing ?


View Replies !   View Related
How To Disable Autmatic Round Of Of A Decimal Number In Sql Server Using
Hi all,
I am sorry if i am posting this error in an inappropriate froum.
Well in my intranet web application i want to enter a number to the database(sql sever 2005) that has a column(schoolkm) whose type is decimal(9, 2). Now if i want to enter the value 1.5 in the text box and enter that value to the database through interface then that value automatically rounds to 2. But when i get into the table and enter that value by hand then that value enters perfectly i.e. without rounding of. I want to know the reason and how can i cure this problem.
Regards & thanks in advance

View Replies !   View Related
Problem With CAST And CONVERT In SQL Server2000 Converting Decimal Places From 4 To 2
All of my currency columns are only storing 2 decimal places when I insert into the database but when I pull out the data with a SELECT statement, I always get 4 decimal places instead of the 2 that were inserted. 
For example: 
Database Price            SELECT statement Price
100.56                           100.5600
I have tried to use the CAST and/or CONVERT commands but I cannot get the output to come out as 100.56.  Has anyone had a similar problem?

View Replies !   View Related
Rounding To 2 Decimal Places In Derived Column Transform Editor
I want to replace the contents of a value column with itself but rounded to 2 decimal places.

The current column is a double and I have tried to perform this using the following expression but it fails to work.

Code Snippet

How should I achieve this?

View Replies !   View Related
Decimal Places Error On Opening SQLServer Table From Access Project
One single table when openen from a MSAccess project file gives error:

The setting for DecimalPlaces property must be from 0 through 15, 255 for Auto (default).

After which the table is openend normally. I don't recall setting Decimal Places to the table. The only numeric fields are two INTs that are also ID's (PK and FK). This error occurs also when recreating the db project. These fields can not be edited eitther from MSAccess nor Enterprise Manager.

What can be done on the table, resp. MSAccess to change this?

View Replies !   View Related
Can't Get Decimal To Show Up!
Hey...I've been cracking head about this one all day, and I'm sure it'san easy answer, but here goes:I have a column entitled Sequ which is defined as a Decimal withPrecision 10 and Scale 5. In an ASP.NET page, I'm performing acalculation which is inserted into the Sequ column. I'm doing aresponse.write, which enables me to see that the numbers are in factbeing calculated correctly complete with a string of numbers after thedecimal, but when I pull the numbers out to use on the page or accessthe table, Sequ lists all numbers as integers. I'm using a storedprocedure in which I'm declaring the @calc parameter (the calculatedvalue which is being inserted) as a Decimal -- I don't know what I'mdoing wrong. Help appreciated...thanks.Erik

View Replies !   View Related
Show The Decimal Part In Query
Hi,In the following query the calculator gives value 3.3  but the query returns 3.0 I need to get the decimal part also. i.e I need to get 3.3 as answer from the query. select cast(66/20 as decimal(6,2)) Need help.Thanks 

View Replies !   View Related
How To Show Decimal Poin In A Result Set?

I have a field with dataqtype INT. I need to avg this field value and show in decimal with two points, which convert function do I use?

Thanks in advance!

View Replies !   View Related
How Can I Show One Decimal On Time (urgent)

I have a column in a table that has numbers. How can i convert my number from this 2.36 to 2.4
2.53 to 3.0


View Replies !   View Related
Legacy Database Uses Decimal Data Types.--&> AutomobileTypeId (PK, Decimal(10,0), Not Null) Why Not Integers Instead ?
I am working with a legacy SQL server database from SQL Server 2000. I noticed that in some places that they use decimal data types, that I would normally think they should be using integer data types. Why is this does anyone know?
Example: AutomobileTypeId (PK, decimal(10,0), not null)

View Replies !   View Related

Copyright 2005-08, All rights reserved