Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Access query vs. Excel query

I have been given an existing Access query and I am attempting to duplicate it in Excel. I have gotten close, but I have virtually no experience with SQL, and I am guessing that's where the answer lies.

Here is the SQL from the Access query:

SELECT DISTINCTROW Delivery.Promised_Date, Customer.Name, Job.Part_Number, Delivery.Promised_Quantity, Delivery.Job, Job.Customer_PO, Job.Customer_PO_LN, Job.Drawing, Delivery.Comment, Delivery.Packlist, Job.Status, Material_Location.Location_ID, Material_Location.On_Hand_Qty
FROM ((Customer INNER JOIN (Job INNER JOIN Material ON Job.Part_Number = Material.Material) ON Customer.Customer = Job.Customer) INNER JOIN Delivery ON Job.Job = Delivery.Job) LEFT JOIN Material_Location ON Material.Material = Material_Location.Material
WHERE (((Delivery.Promised_Date) Between [Start Date] And [End Date]) AND ((Delivery.Packlist) Is Null) AND ((Job.Status)="Complete" Or (Job.Status)="Active"))
ORDER BY Delivery.Promised_Date, Customer.Name, Job.Part_Number;

And here is the SQL from the Excel query that I developed:

SELECT Delivery.Promised_Date, Delivery.Job, Customer.Name, Job.Part_Number, Material.Description, Delivery.Promised_Quantity, Material_Location.On_Hand_Qty, Material_Location.Location_ID, Material_Location.Lot, Job.Ship_Via, Job.Customer_PO, Job.Customer_PO_LN, Job.Status
FROM EbscoJB.dbo.Customer Customer, EbscoJB.dbo.Delivery Delivery, EbscoJB.dbo.Job Job, EbscoJB.dbo.Material Material, EbscoJB.dbo.Material_Location Material_Location
WHERE Job.Customer = Customer.Customer AND Delivery.Job = Job.Job AND Job.Part_Number = Material.Material AND Material.Material = Material_Location.Material AND ((Delivery.Promised_Date Between ? And ?) AND (Delivery.Packlist Is Null) AND (Job.Status In ('Active','Complete')))
ORDER BY Delivery.Promised_Date, Customer.Name, Material_Location.Location_ID

The problem I am experiencing is that the Access Query returns the data that I need. The Excel query does not return a record if the "On_Hand_Qty" field is blank. Thus, for the same date range, I get 36 records in Access, and 29 records in Excel. I need to see all the data, regardless of whether the "On_Hand_Qty" field contains data or not.

I know the problem exists in the joins of the two queries, but I don't know how to get over this hurdle. The LEFT JOIN in the Access query is the tangible that gives me the extra 6 records. I have tried to rewrite the SQL for the Excel query using the same JOINS as the Access query, but it doesn't work.

HELP!!

d
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Access query vs. Excel query

your assment of the left join is correct. my question is
why you are re-writing the query? Access and excel
understand the same sql. are you accessing a different
database?
-----Original Message-----
I have been given an existing Access query and I am

attempting to duplicate it in Excel. I have gotten close,
but I have virtually no experience with SQL, and I am
guessing that's where the answer lies.

Here is the SQL from the Access query:

SELECT DISTINCTROW Delivery.Promised_Date, Customer.Name,

Job.Part_Number, Delivery.Promised_Quantity, Delivery.Job,
Job.Customer_PO, Job.Customer_PO_LN, Job.Drawing,
Delivery.Comment, Delivery.Packlist, Job.Status,
Material_Location.Location_ID,
Material_Location.On_Hand_Qty
FROM ((Customer INNER JOIN (Job INNER JOIN Material ON

Job.Part_Number = Material.Material) ON Customer.Customer
= Job.Customer) INNER JOIN Delivery ON Job.Job =
Delivery.Job) LEFT JOIN Material_Location ON
Material.Material = Material_Location.Material
WHERE (((Delivery.Promised_Date) Between [Start Date] And

[End Date]) AND ((Delivery.Packlist) Is Null) AND
((Job.Status)="Complete" Or (Job.Status)="Active"))
ORDER BY Delivery.Promised_Date, Customer.Name,

Job.Part_Number;

And here is the SQL from the Excel query that I developed:

SELECT Delivery.Promised_Date, Delivery.Job,

Customer.Name, Job.Part_Number, Material.Description,
Delivery.Promised_Quantity, Material_Location.On_Hand_Qty,
Material_Location.Location_ID, Material_Location.Lot,
Job.Ship_Via, Job.Customer_PO, Job.Customer_PO_LN,
Job.Status
FROM EbscoJB.dbo.Customer Customer, EbscoJB.dbo.Delivery

Delivery, EbscoJB.dbo.Job Job, EbscoJB.dbo.Material
Material, EbscoJB.dbo.Material_Location Material_Location
WHERE Job.Customer = Customer.Customer AND Delivery.Job =

Job.Job AND Job.Part_Number = Material.Material AND
Material.Material = Material_Location.Material AND
((Delivery.Promised_Date Between ? And ?) AND
(Delivery.Packlist Is Null) AND (Job.Status In
('Active','Complete')))
ORDER BY Delivery.Promised_Date, Customer.Name,

Material_Location.Location_ID

The problem I am experiencing is that the Access Query

returns the data that I need. The Excel query does not
return a record if the "On_Hand_Qty" field is blank.
Thus, for the same date range, I get 36 records in Access,
and 29 records in Excel. I need to see all the data,
regardless of whether the "On_Hand_Qty" field contains
data or not.

I know the problem exists in the joins of the two

queries, but I don't know how to get over this hurdle.
The LEFT JOIN in the Access query is the tangible that
gives me the extra 6 records. I have tried to rewrite the
SQL for the Excel query using the same JOINS as the Access
query, but it doesn't work.

HELP!!

d
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Query from Access into Excel cause Access to go to read only T Stephens Excel Discussion (Misc queries) 0 March 24th 09 04:17 PM
Can I use MS Query in Excel like an Append Query in Access Sam Wardill Excel Discussion (Misc queries) 0 April 11th 06 02:41 PM
Microsoft Query rejects "nz" function in Access Query Vaughan Excel Discussion (Misc queries) 0 May 4th 05 05:20 PM
How to use a Access Query that as a parameter into Excel database query Karen Middleton Excel Discussion (Misc queries) 1 December 13th 04 07:54 PM
Excel Access Query Nigel[_8_] Excel Programming 5 February 13th 04 03:41 PM


All times are GMT +1. The time now is 09:39 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"