SubQuery Problem

D

DS

I have two queries, one based on another.
The first query is this.
And is called "QHasChecks"

SELECT tblChecksTMP.ChkTabID, tblChecksTMP.ChkPaid,
tblChecksTMP.ChkServer, tblChecksTMP.ChkPrinted,
tblChecksTMP.ChkDividedCheck, tblChecksTMP.ChkTypeID,
tblChecksTMP.ChkCancelled
FROM tblTabs INNER JOIN tblChecksTMP ON tblTabs.TabID =
tblChecksTMP.ChkTabID
WHERE (((tblChecksTMP.ChkPaid)=0) AND ((tblChecksTMP.ChkPrinted)=0) AND
((tblChecksTMP.ChkDividedCheck)=0) AND ((tblChecksTMP.ChkTypeID) Not
Like 5) AND ((tblChecksTMP.ChkCancelled)=0));

The second query is this.

SELECT tblEmployees.EmployeeID, [EmpFirstName] & " " & [EmpLastName] AS SRV
FROM QHasChecks INNER JOIN tblEmployees ON
QHasChecks.ChkServer=tblEmployees.EmployeeID
GROUP BY tblEmployees.EmployeeID, [EmpFirstName] & " " & [EmpLastName]
ORDER BY [EmpFirstName] & " " & [EmpLastName];

I need to replace the first querys references in the second query with
SQL code, how would I do this?

Thanks
DS
 
M

Michael Gramelspacher

SELECT tblEmployees.EmployeeID,
[EmpFirstName] & " " & [EmpLastName] AS SRV
FROM (SELECT tblChecksTMP.ChkTabID,
tblChecksTMP.ChkPaid,
tblChecksTMP.ChkServer,
tblChecksTMP.ChkPrinted,
tblChecksTMP.ChkDividedCheck,
tblChecksTMP.ChkTypeID,
tblChecksTMP.ChkCancelled
FROM tblTabs
INNER JOIN tblChecksTMP
ON tblTabs.TabID = tblChecksTMP.ChkTabID
WHERE (((tblChecksTMP.ChkPaid) = 0)
AND ((tblChecksTMP.ChkPrinted) = 0)
AND ((tblChecksTMP.ChkDividedCheck) = 0)
AND ((tblChecksTMP.ChkTypeID) NOT LIKE 5)
AND ((tblChecksTMP.ChkCancelled) = 0))) AS QHasChecks
INNER JOIN tblEmployees
ON QHasChecks.ChkServer = tblEmployees.EmployeeID
GROUP BY tblEmployees.EmployeeID,[EmpFirstName] & " " & [EmpLastName]
ORDER BY [EmpFirstName] & " " & [EmpLastName];
 

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

Similar Threads

ORDER BY Problem 4
UnMatched Query 3
UNION QUERY (Sorting) 2
UNION SELECT Problem 2
Joining 2 Queries 3
SQL ORDER BY 1
From External Database 5
Same data from 2 sources 2

Top