added extra features into subquery
added testcases for inserting new record