Union query dropping duplicates

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a simple Union Qry

Select * from table1
where fieldX = between date1 And date2
And
where field x > date2
order by fieldX

union

Select * from table1
where fieldX = between date1 And date3
And where field x > date3
order by fieldX;

Problem:

The qry is not returning duplicate rows.

I am not using a DISTINCT function in any of the code.

Does anyone know whats going on?

When I run the two queries separately their is a duplicate record that
appears in both data sets. But, when I run the query in the Union, only one
record appears.

For example, data set 1, return 20 values, and data set 2 returns 10 values.
But when I union both data sets, only 25 values are retruned.

Why are the others falling off?

Please help.
 
You must have typed the SQL instead of copying and pasting as there appears
to be some errors.
-- You are selecting from Table1 twice.
-- "where fieldX = between date1 And date2 And where field x > date2" ----
FieldX can not be between date1 and date2 and greater than date2 at the same
time.
 
Back
Top