Fixed SQL query problem 

where two values of different type were compared