Sovled some errors while executing SQL