added substring code to sql commonly used