473,388 Members | 1,600 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Combine two queries to create one query with one result set

166 100+
Hello:

I am using two queries to get one result set. The issue is, I return no data when I combine them into one query. I have listed both queries, as well as the 3rd query that shows them combined.

**Max Date/Time Query-Finds the most recent updated record based on the time and date (Correct Results Returned)
SELECT [Yard Panel Number].panelNumber, Max([Yard Location].locDate) AS MaxOflocDate, Max([Yard Location].completionTime) AS MaxOfcompletionTime, [Yard Panel Number].jobNumber, [Yard Location].panelID
FROM [Yard Panel Number], [Yard Location]
WHERE ((([Yard Panel Number].panelID)=[Yard Location].[panelID]))
GROUP BY [Yard Panel Number].panelNumber, [Yard Panel Number].jobNumber, [Yard Location].panelID
ORDER BY [Yard Panel Number].panelNumber;

**From To Query--Finds all record locations (Correct Results Returned)
SELECT [Project Information].jobName, [Project Information].jobNumber, [Yard Location].locationFrom, [Yard Location].locationTo, [Yard Location].panelID, [Yard Location].damage
FROM [Project Information], [Yard Location]
WHERE ((([Project Information].[jobNumber])=[Yard Location].[jobNumber]));

**Finally, Query1--Combines above queries, to find the most recent record of locations, based on the most recent date and time. When I run this query I return NO results
SELECT DISTINCT [FromTo Query].jobName, [FromTo Query].jobNumber, [Max Date/Time Query].panelNumber, [Max Date/Time Query].MaxOflocDate, [Max Date/Time Query].MaxOfcompletionTime, [FromTo Query].locationFrom, [FromTo Query].locationTo
FROM [Max Date/Time Query], [FromTo Query]
WHERE ((([FromTo Query].[paneID])=[Max Date/Time Query].[panelID]))
AND ((([FromTo Query].[jobNumber])=[Max Date/Time Query].[jobNumber]));

I can't figure it out, Please advise!

Any assistance is appreciated.
Apr 2 '08 #1
1 3141
PianoMan64
374 Expert 256MB
Hello:

I am using two queries to get one result set. The issue is, I return no data when I combine them into one query. I have listed both queries, as well as the 3rd query that shows them combined.

**Max Date/Time Query-Finds the most recent updated record based on the time and date (Correct Results Returned)
SELECT [Yard Panel Number].panelNumber, Max([Yard Location].locDate) AS MaxOflocDate, Max([Yard Location].completionTime) AS MaxOfcompletionTime, [Yard Panel Number].jobNumber, [Yard Location].panelID
FROM [Yard Panel Number], [Yard Location]
WHERE ((([Yard Panel Number].panelID)=[Yard Location].[panelID]))
GROUP BY [Yard Panel Number].panelNumber, [Yard Panel Number].jobNumber, [Yard Location].panelID
ORDER BY [Yard Panel Number].panelNumber;

**From To Query--Finds all record locations (Correct Results Returned)
SELECT [Project Information].jobName, [Project Information].jobNumber, [Yard Location].locationFrom, [Yard Location].locationTo, [Yard Location].panelID, [Yard Location].damage
FROM [Project Information], [Yard Location]
WHERE ((([Project Information].[jobNumber])=[Yard Location].[jobNumber]));

**Finally, Query1--Combines above queries, to find the most recent record of locations, based on the most recent date and time. When I run this query I return NO results
SELECT DISTINCT [FromTo Query].jobName, [FromTo Query].jobNumber, [Max Date/Time Query].panelNumber, [Max Date/Time Query].MaxOflocDate, [Max Date/Time Query].MaxOfcompletionTime, [FromTo Query].locationFrom, [FromTo Query].locationTo
FROM [Max Date/Time Query], [FromTo Query]
WHERE ((([FromTo Query].[paneID])=[Max Date/Time Query].[panelID]))
AND ((([FromTo Query].[jobNumber])=[Max Date/Time Query].[jobNumber]));

I can't figure it out, Please advise!

Any assistance is appreciated.
Can you include some data samples returned from each query and what is in the tables also

and you may also include the result that you're looking for visually speaking.

Thanks,

Joe P.
Apr 3 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
2
by: va3wmh | last post by:
I have a table that has two dates in it, a date opened and a date closed. I would like to create one query to give me the number of records that have been opened each month plus, and this is the...
1
by: Chris Lutka | last post by:
I've been racking my brains all day over this. And I'm not the best at SQL either. I need a query that will produce the following results:...
3
by: Alicia | last post by:
Hi, I am trying to match two queries and make it into one query. I have only been about to group similar attributes but nothing that looks like the FinalQuery below. If anyone knows of a query...
1
by: snOOp | last post by:
I am trying to combine the data from two similar tables into one query, but I need for all of the records from both tables to show up and I want the ones that have matching 'emplid' to be combined...
5
by: Jamie Pittman via AccessMonster.com | last post by:
I have two tables with 5000 entries on them. One is based for regular time with several variables example (employee name, date,time in and out, code, customer, building) I have another table that...
4
by: Jason Gyetko | last post by:
Is there any way to combine these two queries into one? I have tables Item_Master & Kit_Master which are the source tables. Query 2 is using both Item_Master (table) & qryKit1 (query) &...
4
by: PlayHard | last post by:
I want my output in two columns like this: C_INCIDENT_TYPE \ TOTAL COUNT How do I combine my two queries to get result. First Query SELECT C_INCIDENT_TYPE, COUNT (*)
2
by: bips2005 | last post by:
i have got two queries, $sql1 = "select cust_id from customer where comp_name = '$compname'"; $result = $DB->query($sql1); $result->fetchInto($row); $sql = "select expirydate from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.