Question

Here's my simplified table (SQL Server 2005):

table1: col1 int, col2 int, col3 cast(col1/col2 as int) [computed column]

for some reason the above doesn't work. i just want to save a WHOLE part of col1/col2, how do i do that?

example: col1 = 5, col2 = 3 ... col3 should be 1
Was it helpful?

Solution

One option would be to use the floor function:

FLOOR(col1/col2)

or

CONVERT(int, FLOOR(col1/col2)) -- Might be overkill

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top