Union query dropping duplicates

  • Thread starter sebastian stephenson
  • Start date
S

sebastian stephenson

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.
 
K

KARL DEWEY

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top