Combine 3 Top 30 Queries to have 90 entries...

  • Thread starter Thread starter Fletcher
  • Start date Start date
F

Fletcher

Hi, I have 3 queries that preform the same operation, but have
different criterium. I would like to combine these queries into one
query for exporting to a analysis program. Is there any way that this
could be done? I tried to write a query that took everything and put
it into one thing, but it did soemthing weird and produced 3672
entries. This isn't what I wnated to happen.

I don't know if you would need my SQL's or not, but i'll put them just
in case:

*FSI1ParticleCalculator*
SELECT TOP 30 Passes.DateTimeOut, Passes.FSINumber, Passes.Pre,
Passes.Post, [Post]-
 AS Particles, Passes.PassID
FROM Passes
WHERE (((Passes.FSINumber)=1))
ORDER BY Passes.DateTimeOut DESC , Passes.PassID;

*FSI3ParticleCalculator*
SELECT TOP 30 Passes.DateTimeOut, Passes.FSINumber, Passes.Pre,
Passes.Post, [Post]-
 AS Particles, Passes.PassID
FROM Passes
WHERE (((Passes.FSINumber)=3))
ORDER BY Passes.DateTimeOut DESC , PassID;

*FSI4ParticleCalculator*
SELECT TOP 30 Passes.DateTimeOut, Passes.FSINumber, Passes.Pre,
Passes.Post, [Post]-
 AS Particles, Passes.PassID
FROM Passes
WHERE (((Passes.FSINumber)=4))
ORDER BY Passes.DateTimeOut DESC , PassID;


Thanks in advance,

Fletcher...
 
Fletcher

Take a look at Access HELP for the syntax on the UNION query. Basically,
you'll have...

SELECT ...

UNION

SELECT ...

UNION

SELECT...;

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Jeff,
I'm not sure that will work since the TOP predicate uses an order by clause
and I think that ORDER BY clauses are ignored in UNION queries (except for
the last one).

I guess the poster could try it and see. If it fails, then there are some
other possible solutions.
Jeff Boyce said:
Fletcher

Take a look at Access HELP for the syntax on the UNION query. Basically,
you'll have...

SELECT ...

UNION

SELECT ...

UNION

SELECT...;

Regards

Jeff Boyce
Microsoft Office/Access MVP


Fletcher said:
Hi, I have 3 queries that preform the same operation, but have
different criterium. I would like to combine these queries into one
query for exporting to a analysis program. Is there any way that this
could be done? I tried to write a query that took everything and put
it into one thing, but it did soemthing weird and produced 3672
entries. This isn't what I wnated to happen.

I don't know if you would need my SQL's or not, but i'll put them just
in case:

*FSI1ParticleCalculator*
SELECT TOP 30 Passes.DateTimeOut, Passes.FSINumber, Passes.Pre,
Passes.Post, [Post]-
 AS Particles, Passes.PassID
FROM Passes
WHERE (((Passes.FSINumber)=1))
ORDER BY Passes.DateTimeOut DESC , Passes.PassID;

*FSI3ParticleCalculator*
SELECT TOP 30 Passes.DateTimeOut, Passes.FSINumber, Passes.Pre,
Passes.Post, [Post]-
 AS Particles, Passes.PassID
FROM Passes
WHERE (((Passes.FSINumber)=3))
ORDER BY Passes.DateTimeOut DESC , PassID;

*FSI4ParticleCalculator*
SELECT TOP 30 Passes.DateTimeOut, Passes.FSINumber, Passes.Pre,
Passes.Post, [Post]-
 AS Particles, Passes.PassID
FROM Passes
WHERE (((Passes.FSINumber)=4))
ORDER BY Passes.DateTimeOut DESC , PassID;


Thanks in advance,

Fletcher...

 
Oops! You might be right.

You might have to create the multiple "TOP" queries, then use something
like:

SELECT * FROM Query1
UNION
SELECT * FROM Query2
UNION
....

Regards

Jeff Boyce
Microsoft Office/Access MVP


John Spencer said:
Jeff,
I'm not sure that will work since the TOP predicate uses an order by
clause and I think that ORDER BY clauses are ignored in UNION queries
(except for the last one).

I guess the poster could try it and see. If it fails, then there are some
other possible solutions.
Jeff Boyce said:
Fletcher

Take a look at Access HELP for the syntax on the UNION query. Basically,
you'll have...

SELECT ...

UNION

SELECT ...

UNION

SELECT...;

Regards

Jeff Boyce
Microsoft Office/Access MVP


Fletcher said:
Hi, I have 3 queries that preform the same operation, but have
different criterium. I would like to combine these queries into one
query for exporting to a analysis program. Is there any way that this
could be done? I tried to write a query that took everything and put
it into one thing, but it did soemthing weird and produced 3672
entries. This isn't what I wnated to happen.

I don't know if you would need my SQL's or not, but i'll put them just
in case:

*FSI1ParticleCalculator*
SELECT TOP 30 Passes.DateTimeOut, Passes.FSINumber, Passes.Pre,
Passes.Post, [Post]-
 AS Particles, Passes.PassID
FROM Passes
WHERE (((Passes.FSINumber)=1))
ORDER BY Passes.DateTimeOut DESC , Passes.PassID;

*FSI3ParticleCalculator*
SELECT TOP 30 Passes.DateTimeOut, Passes.FSINumber, Passes.Pre,
Passes.Post, [Post]-
 AS Particles, Passes.PassID
FROM Passes
WHERE (((Passes.FSINumber)=3))
ORDER BY Passes.DateTimeOut DESC , PassID;

*FSI4ParticleCalculator*
SELECT TOP 30 Passes.DateTimeOut, Passes.FSINumber, Passes.Pre,
Passes.Post, [Post]-
 AS Particles, Passes.PassID
FROM Passes
WHERE (((Passes.FSINumber)=4))
ORDER BY Passes.DateTimeOut DESC , PassID;


Thanks in advance,

Fletcher...

 
Actually Jeff, that's what I wanted to do originally. I wanted to take
the 3 queries and combine them into one with another query. And I used
what you told me earlier only selecting from the three TOP queries. So
thank you. It works awesome.
Jeff said:
Oops! You might be right.

You might have to create the multiple "TOP" queries, then use something
like:

SELECT * FROM Query1
UNION
SELECT * FROM Query2
UNION
...

Regards

Jeff Boyce
Microsoft Office/Access MVP


John Spencer said:
Jeff,
I'm not sure that will work since the TOP predicate uses an order by
clause and I think that ORDER BY clauses are ignored in UNION queries
(except for the last one).

I guess the poster could try it and see. If it fails, then there are some
other possible solutions.
Jeff Boyce said:
Fletcher

Take a look at Access HELP for the syntax on the UNION query. Basically,
you'll have...

SELECT ...

UNION

SELECT ...

UNION

SELECT...;

Regards

Jeff Boyce
Microsoft Office/Access MVP


Hi, I have 3 queries that preform the same operation, but have
different criterium. I would like to combine these queries into one
query for exporting to a analysis program. Is there any way that this
could be done? I tried to write a query that took everything and put
it into one thing, but it did soemthing weird and produced 3672
entries. This isn't what I wnated to happen.

I don't know if you would need my SQL's or not, but i'll put them just
in case:

*FSI1ParticleCalculator*
SELECT TOP 30 Passes.DateTimeOut, Passes.FSINumber, Passes.Pre,
Passes.Post, [Post]-
 AS Particles, Passes.PassID
FROM Passes
WHERE (((Passes.FSINumber)=1))
ORDER BY Passes.DateTimeOut DESC , Passes.PassID;

*FSI3ParticleCalculator*
SELECT TOP 30 Passes.DateTimeOut, Passes.FSINumber, Passes.Pre,
Passes.Post, [Post]-
 AS Particles, Passes.PassID
FROM Passes
WHERE (((Passes.FSINumber)=3))
ORDER BY Passes.DateTimeOut DESC , PassID;

*FSI4ParticleCalculator*
SELECT TOP 30 Passes.DateTimeOut, Passes.FSINumber, Passes.Pre,
Passes.Post, [Post]-
 AS Particles, Passes.PassID
FROM Passes
WHERE (((Passes.FSINumber)=4))
ORDER BY Passes.DateTimeOut DESC , PassID;


Thanks in advance,

Fletcher...

 

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

Back
Top