update sql for smarties page