Click here to Skip to main content
15,792,409 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
sir, i have a simple query :-

select sname,35+(50-35)*(20/50) as tt from student

the answer of this equation is 6 but it give 35. what is my mistake.
TCS54321 29-Aug-14 7:51am    
i solve it.. thanks

First of all,the result of that equation should be 41 (35+(50-35)*(20/50) in Google )

To get the this result,you should do something like

select 35+(50-35) * (CONVERT(DECIMAL(4,2), 20) / CONVERT(DECIMAL(4,2), 50)) as tt

Hope it helps
Share this answer
try this
select sname,35+((50.0-35.0)*(20.0/50.0)) as tt from student

as default it int so convert then into float.
Share this answer

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