solve the expression to sql first