Nested SQL statements

  • Thread starter Thread starter mikezcg
  • Start date Start date
M

mikezcg

im not great at sql and need to nest these statements ( for speed) but
cant get it i would appreciate any help thanks"

SELECT qryExistingPersons.Person,
qryExistingPersons.SumOfInvoiceAmount, qryExistingPersons.CheckNum,
qryExistingPersons.Deal, qryExistingPersons.Reference
FROM qryExistingPersons LEFT JOIN Employee ON
qryExistingPersons.Person = Employee.EmployeeName
WHERE (((Employee.EmployeeName) Is Null));


qryExistingPersons :

SELECT Detail.Person, Sum(Detail.InvoiceAmount) AS SumOfInvoiceAmount,
Detail.CheckNum, Detail.Deal, Detail.Reference
FROM Detail
GROUP BY Detail.Person, Detail.CheckNum, Detail.Deal,
Detail.Reference;
 
I'm not sure what you mean by nested, but if you're concerned about
performance, you can create a stored procedure that returns two result
sets (make sure to set the SET NOCOUNT ON option so you don't get 3).
However you do it, each result set is a separate trip across the
network. Also, make sure that your tables are properly indexed.

-- Mary
MCW Technologies
http://www.mcwtech.com

im not great at sql and need to nest these statements ( for speed) but
cant get it i would appreciate any help thanks"

SELECT qryExistingPersons.Person,
qryExistingPersons.SumOfInvoiceAmount, qryExistingPersons.CheckNum,
qryExistingPersons.Deal, qryExistingPersons.Reference
FROM qryExistingPersons LEFT JOIN Employee ON
qryExistingPersons.Person = Employee.EmployeeName
WHERE (((Employee.EmployeeName) Is Null));


qryExistingPersons :

SELECT Detail.Person, Sum(Detail.InvoiceAmount) AS SumOfInvoiceAmount,
Detail.CheckNum, Detail.Deal, Detail.Reference
FROM Detail
GROUP BY Detail.Person, Detail.CheckNum, Detail.Deal,
Detail.Reference;
 
Back
Top