Fixing concatenation of sql