Handle Sql query query count gracefuly