Hi VJay, When you are querying the data using query editor, it will return all the records according to the query. It runs in the system context. Here sharing settings are not taken into account.
When you query data using class where with sharing keyword is used, it runs in user context. It means if the OWD is private for the sObject for which the query is written/executed, it only returns the records whose owner is the current user and the records shared with the same user.
So in your case, you have 2 records for an SObject and OWD is private and no sharing is used with the user who is running the class(with sharing).
Are you using the keyword 'with sharing' while declaring your class?
If yes then, remove that and try.
Let me know if it helps!
When you are querying the data using query editor, it will return all the records according to the query. It runs in the system context. Here sharing settings are not taken into account.
When you query data using class where with sharing keyword is used, it runs in user context. It means if the OWD is private for the sObject for which the query is written/executed, it only returns the records whose owner is the current user and the records shared with the same user.
So in your case, you have 2 records for an SObject and OWD is private and no sharing is used with the user who is running the class(with sharing).