Update the SQL template for better result checking