COMBINING TWO QUERIES

J

JOE POLLOCK

I HAVE TWO QUERIES WHICH I HAVE PRODUCED REPORTS FOR. ONE QUERY REPRESENTS
SALES FROM YEAR 1 AND THE OTHER SALES FROM YEAR 2. WHAT IS THE BEST WAY TO
COMBINE THESE TWO SETS OF INFORMATION SO THAT I CAN SEE, SIDE BY SIDE, THE
SALES FOR EACH YEAR, SORTED BY CUSTOMER.


ANY SUGGESTIONS WOULD BE GREATLY APPRECIATED.

REGARDS
 
K

KARL DEWEY

You can use a union query or change your query to use only one.
Year 1 Sales: Sum(IIF([Year]= 2005, [Sales], 0)
Year 2 Sales: Sum(IIF([Year]= 2006, [Sales], 0)
 
J

JOE POLLOCK

WHAT WOULD THE SQL CODE LOOK LIKE FOR A UNION QUERY?
--
JOE


KARL DEWEY said:
You can use a union query or change your query to use only one.
Year 1 Sales: Sum(IIF([Year]= 2005, [Sales], 0)
Year 2 Sales: Sum(IIF([Year]= 2006, [Sales], 0)

--
KARL DEWEY
Build a little - Test a little


JOE POLLOCK said:
I HAVE TWO QUERIES WHICH I HAVE PRODUCED REPORTS FOR. ONE QUERY REPRESENTS
SALES FROM YEAR 1 AND THE OTHER SALES FROM YEAR 2. WHAT IS THE BEST WAY TO
COMBINE THESE TWO SETS OF INFORMATION SO THAT I CAN SEE, SIDE BY SIDE, THE
SALES FOR EACH YEAR, SORTED BY CUSTOMER.


ANY SUGGESTIONS WOULD BE GREATLY APPRECIATED.

REGARDS
 
K

KARL DEWEY

Like this --
SELECT Year([Date open]) AS [Sales Year], Sum([Change Requests].x) AS [Sales
QTY]
FROM [Change Requests]
GROUP BY Year([Date open])
HAVING (((Year([Date open])) = 2005 ))
UNION SELECT Year([Date open]) AS [Sales Year], Sum([Change Requests].x) AS
[Sales QTY]
FROM [Change Requests]
GROUP BY Year([Date open])
HAVING (((Year([Date open])) = 2006 ));

Or use this ---
SELECT Sum(IIf([Year]=2005,[Sales],0)) AS [Year 2005 Sales],
Sum(IIf([Year]=2006,[Sales],0)) AS [Year 2006 Sales]
FROM [Annual Sales];
--
KARL DEWEY
Build a little - Test a little


JOE POLLOCK said:
WHAT WOULD THE SQL CODE LOOK LIKE FOR A UNION QUERY?
--
JOE


KARL DEWEY said:
You can use a union query or change your query to use only one.
Year 1 Sales: Sum(IIF([Year]= 2005, [Sales], 0)
Year 2 Sales: Sum(IIF([Year]= 2006, [Sales], 0)

--
KARL DEWEY
Build a little - Test a little


JOE POLLOCK said:
I HAVE TWO QUERIES WHICH I HAVE PRODUCED REPORTS FOR. ONE QUERY REPRESENTS
SALES FROM YEAR 1 AND THE OTHER SALES FROM YEAR 2. WHAT IS THE BEST WAY TO
COMBINE THESE TWO SETS OF INFORMATION SO THAT I CAN SEE, SIDE BY SIDE, THE
SALES FOR EACH YEAR, SORTED BY CUSTOMER.


ANY SUGGESTIONS WOULD BE GREATLY APPRECIATED.

REGARDS
 

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

Top