Two SELECT statements in one query

jaanisf

Registered User.
Local time
Today, 03:21
Joined
Apr 29, 2003
Messages
32
I need two SELECT statements in one query, because it cannot be done by one statement. Can it be done somehow?

Example:

SELECT Field0, Sum(Field1 * Field2)
FROM Table1
WHERE Field3 <> 'text' AND Field4 >= Forms!Form1!txtbox1 and Field4 <= Forms!Form1!txtbox2

SELECT Field0, Sum(Field1 * (Field2/100))
FROM Table1
WHERE Field3 = 'text' AND Field4 >= Forms!Form1!txtbox1 and Field4 <= Forms!Form1!txtbox2

I need both these two statements showed in one query datasheet view. I need more, I need them both mixed and sorted by those sums.
 
Study up on union queries:

SELECT Field0, Sum(Field1 * Field2)
FROM Table1
WHERE Field3 <> 'text' AND Field4 >= Forms!Form1!txtbox1 and Field4 <= Forms!Form1!txtbox2;

UNION SELECT Field0, Sum(Field1 * (Field2/100))
FROM Table1
WHERE Field3 = 'text' AND Field4 >= Forms!Form1!txtbox1 and Field4 <= Forms!Form1!txtbox2;
 
Wow, many thanks ;) It all cames out just so simple ;)
 

Users who are viewing this thread

Back
Top Bottom