To give access to the records that are to be used in query,
we have create a new query security tree and add the records which we want to
give the access and then assign a access group to the tree. After that we have
to add that query tree and query access group to the permission list.
For details visit here.