Query to return one digit after decimal place in SQL Server

Last Reply one month ago By dharmendr

Posted one month ago

User Interface: Electricity use: 3400.00(value coming from db by the below query)

I wanted to put validation for the below query such that it should be 3400.0 :

SELECT @RESULT =ENQ.ELECTRICITY_USE FROM REG_REGISTRATION_MST_T REG JOIN ENQ_ENQUIRY_MST_T ENQ ON REG.ENQ_ID=ENQ.ENQUIRY_ID WHERE REG.REGISTRATION_ID=

 

 

Posted one month ago Modified on one month ago

Hi chetan,

Use Cast function for rounding to 1 decimal place in SQL Server.

Query

DECLARE @Electricity VARCHAR(10)
SET @Electricity = '3400.84' 
SELECT CAST(@Electricity AS DECIMAL(18,1)) AS Electricity

Output

Electricity
3400.0