Run these queries:SELECT 5/4SELECT 5e0/4e0SELECT CAST(5 as real)/CAST(4 as real)
In the first, you get the result in the same data type as the inputs, so you'll need to cast the results of your counts.As for the code you have posted, it shouldn't even work! You must have got a syntax error running that. Also, why are you dividing total active items by active items out of stock? That'll give you a percentage over 100%. SELECT Percentage=1-CAST(count(nullif(Qty_Stk,0)) as real)/ --use nullif as count only counts non null results. Assuming no null results exist for Qty_Stk, otherwise change CAST(count(1) as real) FROM Items WHERE active='t'