I am trying to get % change between 2 columns values in table. I am bit confused as to why % change is always returned as 0.
-- create
CREATE TABLE Host
(
HostName Varchar(100),
tcCount int,
PrCount int
);
-- insert
INSERT INTO Host (HostName, tcCount, prCount)
VALUES ('AppServer04', 125, 5852);
INSERT INTO Host (HostName, tcCount, prCount)
VALUES ('AppServer05', 300 , 4318);
-- fetch
SELECT
HostName, tcCount, PrCount,
(prCount - tcCount) / prCount * 100 AS 'Change(%)'
FROM
Host
Result I am getting of above is below:
HostName tcCount PrCount Change(%)
---------------------------------------------- ----------- ----------- -----------
AppServer04 125 5852 0
AppServer05 300 4318 0
(2 rows affected)
For AppServer04 % change should be 97.86 while AppServer05 should be 93.05. I am bit confused as to why I get 0 for both rows..
Am I missing anything here??