`declare @totalItems int,
@totalPeople int,
@averageThings float;
select @totalItems = count(*) from table1
select @totalpeople = count(*) from tblvisits
select @averageThings = cast(@totalItems/@totalPeople as float)
select @averageThings, @totaPeople, @totalItems
This returns an integer instead of a float, I tried with and without the cast as float and got the same results, how to make it return a float
No, it returns a float. The value of the float may be an integer, but the type is a float. Which also answers your real question: you must perform the division using float operands, not cast the result of int division to float:
Your code will break with divide_by_zero if
tblvisitsis empty…