Click here to Skip to main content
15,885,890 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
it displays 0 value in [PER] field or column


What I have tried:

SELECT SMC_No, ShareHolderName, Kita / b.TotKitta * 100 AS [PER] FROM vShareHolderName,
(SELECT TotKitta FROM vShareCert) b ORDER by SMC_No
Posted
Updated 13-Oct-17 0:22am
Comments
Richard MacCutchan 13-Oct-17 6:20am    
What are the values in the fields that you use for the calculations?

1 solution

Integer division, probably.
Try this:
SELECT SMC_No, ShareHolderName, CAST(Kita AS FLOAT) / CAST(b.TotKitta AS FLOAT) * 100 AS [PER] FROM vShareHolderName, 
(SELECT TotKitta FROM vShareCert) b ORDER by SMC_No
 
Share this answer
 
Comments
sulomila 13-Oct-17 6:50am    
thank you very much for prompt reply

i tried this way
CAST(Kita AS numeric(18,4)) / CAST(b.TotKitta AS numeric(18,4))
but it displays like '0.123456789'

actually i need

'0.1234' instead of '0.123456789'
OriginalGriff 13-Oct-17 6:59am    
CAST(CAST(Kita AS numeric(18,4)) / CAST(b.TotKitta AS numeric(18,4)) AS NUMERIC(18,4))
sulomila 13-Oct-17 7:04am    
Thanks
OriginalGriff 13-Oct-17 7:10am    
You're welcome!

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