Add order to sql input query