Same query when doing UNION returning different record count

Tools & Utilities
Enthusiast

Same query when doing UNION returning different record count

Hi,

 

I have written a query that returns a record count as 1017414. Now  I have done UNION using exactly same query. When I UNION the two exaclty same queries it should return the same record count which it return when ran individually but after union, it is returning record count as 991166

 

QUERY1

UNION

QUERY1

 

Any idea why this is happening?

 

Regards,
Mayank
1 REPLY
Senior Apprentice

Re: Same query when doing UNION returning different record count

Hi,

Remember that a UNION will remove duplicate rows (from Query1 and Query2).

Have you tried using 'UNION ALL' instead?

Cheers,

Dave

Ward Analytics Ltd - information in motion
www: http://www.ward-analytics.com