Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

join multiple query results into 1 query

Posted on 2014-02-05
7
Medium Priority
?
256 Views
Last Modified: 2014-02-06
hey guys, i have 3 complex queries and they each give me just 1 value

so for example

Query 1: Output result --> 137
Query 2: Output result --> 33
Query 3: Output result --> 104

there is only 1 cell for each of the output results

Question: how do i join these into 1 resultant queries with 3 cells in 1 row?

i was thinking of using a union query but i don't think that will work as i am trying to add columns instead of rows

i was thinking about outer join but i don't have a unique key

the only way i can think of so far is to write it to a temporary table and then do a select query from there.

thanks in advance guys!
0
Comment
Question by:developingprogrammer
  • 3
  • 3
7 Comments
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 39838031
Hello developingprogrammer,

In my opinion, a union query will suffice with your requirement. You can design it using a sample below:


SELECT DISTINCT tblSample.TestField
FROM tblSample
WHERE (((tblSample.TestField)="Emp1"))

UNION ALL

SELECT DISTINCT tblSample.TestField
FROM tblSample
WHERE (((tblSample.TestField)="Emp2"))

UNION ALL

SELECT DISTINCT tblSample.TestField
FROM tblSample
WHERE (((tblSample.TestField)="Emp3"));


Sincerely,

Ed
0
 

Author Comment

by:developingprogrammer
ID: 39838082
hi Ed, thanks for your response!

so the result would be 1 column with 3 rows is that correct?

let's say just for moot i really need 3 columns in 1 row, how can i achieve that? thanks! = )
0
 
LVL 19

Expert Comment

by:MINDSUPERB
ID: 39838097
Just ignore my post:

"as i am trying to add columns instead of rows"

I missed that part in your question.

Sincerely,

Ed
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 19

Accepted Solution

by:
MINDSUPERB earned 1000 total points
ID: 39838104
You can create a Crosstab out from the union query.

Ed
0
 

Author Comment

by:developingprogrammer
ID: 39838110
whao i didn't think of that. ok i need to go and read up on crosstab queries. good idea, thanks Ed!
0
 
LVL 49

Assisted Solution

by:Dale Fye
Dale Fye earned 1000 total points
ID: 39838479
Actually, you could simply try:

Select qry1.Field1, qry2.Field1, qry3.Field1
FROM qry1, qry2, qry3

This is a Cartesian join, all combinations of all records from all queries.
0
 

Author Comment

by:developingprogrammer
ID: 39840875
whao Dale, that is a fantastic idea! i really like your idea and i also really like Ed's idea. they both serve different purposes and in this case both work. thanks so much for chipping in Dale! = )
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Suggested Courses

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question