Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I write this query

select hours*rate from expenses

hour = numeric(18,2)
rate = numeric(18,1)

I get result: 18.000
27.897
23.560
45.670

But i need only 2 digit after decimal (e.g 23.89). And i dnt want to change in data type. Anybody knows that how can i solve this by sql query.
Posted

Hello,
Try ROUND function ...

select round((hours*rate),2) from expenses..

NB: Please confirm the syntax

Regards
Sebastian
 
Share this answer
 
v3
Comments
Mas11 15-Jun-12 7:27am    
Thanks for reply..
Sandeep Mewara 15-Jun-12 11:51am    
Yep. 5!
Something like this:

SQL
SELECT CAST(ROUND(27.897, 2, 1) as DECIMAL(18,2)) 


Look at documentation for ROUND[^].
 
Share this answer
 
Comments
Mas11 15-Jun-12 7:27am    
Thanks a lot Manas, It worked..
Manas Bhardwaj 15-Jun-12 7:30am    
Glad it helped :)
VJ Reddy 15-Jun-12 7:28am    
Good answer. 5!
Manas Bhardwaj 15-Jun-12 7:30am    
thx!
Espen Harlinn 15-Jun-12 8:30am    
5'ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900