Link to home
Start Free TrialLog in
Avatar of Patrick O'Dea
Patrick O'DeaFlag for Ireland

asked on

SQL Round function - variable

I have a product table that has 3 fields;

ProductCode
Price (to 4 decimals)
DecimalIndicator (this is the number of decimal places that the price will be rounded to)

The decimal indicator will be a number between 0 and 4.

Example:
Price = 12.2412

If the decimal indicator is "2" then the price will display as 12.24
If the decimal indicator is "4" then the price will display as 12.2412

I will be using round(Price,X) to determine the price where X is the decimalindicator.

How can I amend my sql Round function to handle this variable decimal place?

Thank you and good night from Ireland!
ASKER CERTIFIED SOLUTION
Avatar of Sharath S
Sharath S
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Patrick O'Dea

ASKER

Thanks - that was easy!