Avatar of batman32
batman32

asked on 

SQL2000 Round Function

Hi All,
Can you please help on the following function:
SELECT dbo.Duration * dbo.Price AS TOTAL_PRICE

The current result rounds of with no decimal places. How can we have TOTAL_PRICE with 5 decimal places even if it shows for example 5.00000

Thanks!
Microsoft SQL Server

Avatar of undefined
Last Comment
chiragkhabaria
ASKER CERTIFIED SOLUTION
Avatar of chiragkhabaria
chiragkhabaria

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of batman32
batman32

ASKER

Thanks,
It works, but why we getting the last result as currency? ex $ 5.7980
SELECT dbo.Duration * , Cast(Round(dbo.Price,0) As Decimal(7,6)) AS TOTAL_PRICE
Avatar of batman32
batman32

ASKER

dbo.Price,0 made Total Price 0
can you post what query you wrote..

You have to write the ROUND Function.. before that .. have a look at my query again..

Select Cast (Round(5.7980,0) as decimal(7,6))
Avatar of batman32
batman32

ASKER


HI,
SELECT dbo.Duration * Cast(dbo.Price As Decimal(7,6)) AS TOTAL_PRICE
is working, please tell us how to change the curency from US $ to anything else. All our fields are numeric....

Thanks!
you mean to say you are getting the output with $ sign?? can you post what kind of output u r getting
Avatar of batman32
batman32

ASKER

USD (dollar sign) is our otput, but we need it just numeric
SELECT Cast(dbo.Duration * Cast(dbo.Price As Decimal(7,6))  As numeric (6,7) AS TOTAL_PRICE

??
Avatar of batman32
batman32

ASKER

Incorrect syntax near '6'
opps typo

SELECT Cast(dbo.Duration * Cast(dbo.Price As Decimal(7,6))  As numeric (7,6)) AS TOTAL_PRICE
Avatar of batman32
batman32

ASKER

Arithmetic overflow error converting numeric to data type numeric.
The statement has been terminated.

Dude, we are completely lost...
Are you using Query Analyser for running this..

Then do the following setting

1) Go to the Tools --> Options

2) In the Options go to the Connection Property.

3) There uncheck the option Use Regional Setting....

4) Then run this query..

SELECT dbo.Duration * Cast(dbo.Price As Decimal(7,6)) AS TOTAL_PRICE

Hope fully it should work fine..
Microsoft SQL Server
Microsoft SQL Server

Microsoft SQL Server is a suite of relational database management system (RDBMS) products providing multi-user database access functionality.SQL Server is available in multiple versions, typically identified by release year, and versions are subdivided into editions to distinguish between product functionality. Component services include integration (SSIS), reporting (SSRS), analysis (SSAS), data quality, master data, T-SQL and performance tuning.

171K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo