 <p>I finally got to find out the issue I was facing. It was indeed an Oracle issue after the upgrade to Oracle 12C. We talked to the Oracle Support and they responded back with the below: Queries involving hash joins were returning wrong results in cases where hash join would receive row sets as input and produced one row at a time as output. </p> <p>Because of this, the query was becoming indeterministic and giving different counts at different instances. When the query was running in SQL Developer with where clause, SQL developer was providing a different output because of where clause, since it was changing the plan of execution but when I was pasting it in Excel and then filtering, it was showing different values since in this case, the query plan was different since there was no where clause.</p> <p>Sorry if my question caused any kind of confusion. I just wanted to confirm if it was something else before asking DBA to reach out to the Oracle Support regarding this.</p>