A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Multiple Tables in Query not Listing Data.



 
 
Thread Tools Display Modes
  #1  
Old March 15th, 2010, 05:05 PM posted to microsoft.public.access.queries
ty
external usenet poster
 
Posts: 101
Default Multiple Tables in Query not Listing Data.

I cannot seem to get this correct. I am trying to run a query on two
databases one of which is linked to the other. I am trying to get the query
to display a 0 for the total defects counted from one table based on the date
and time from another table. So far when I run the query I get only the
counts from the values that are not null.

Here is the SQL Statement:

SELECT Pro_Total_by_Cell.Cell, Pro_Total_by_Cell.Shift,
Pro_Total_by_Cell.Time, Pro_Total_by_Cell.ProTotal, Pro_Total_by_Cell.Time1,
Hourly_Defects_by_Cell3.CountofFC, Control_Limit_by_Cell.UCL,
IIf(IsNull([CountofFC]),"0",[CountofFC]/[ProTotal]) AS [Percent Defective]
FROM TimeCovTable INNER JOIN (Control_Limit_by_Cell INNER JOIN
(Hourly_Defects_by_Cell3 INNER JOIN Pro_Total_by_Cell ON
(Hourly_Defects_by_Cell3.Cell = Pro_Total_by_Cell.Cell) AND
(Hourly_Defects_by_Cell3.Time2 = Pro_Total_by_Cell.Time1)) ON
Control_Limit_by_Cell.Cell = Hourly_Defects_by_Cell3.Cell) ON
(TimeCovTable.TimeID = Pro_Total_by_Cell.Time1) AND (TimeCovTable.Time =
Pro_Total_by_Cell.Time)
GROUP BY Pro_Total_by_Cell.Cell, Pro_Total_by_Cell.Shift,
Pro_Total_by_Cell.Time, Pro_Total_by_Cell.ProTotal, Pro_Total_by_Cell.Time1,
Hourly_Defects_by_Cell3.CountofFC, Control_Limit_by_Cell.UCL;


Results below.

Cell Shift Time ProTotal Time1 CountofFC UCL Percent Defective
CELL 2 1 8:00 AM 46 8 1 0.045 2.17391304347826E-02



If you need further explanation please let me know.

  #2  
Old March 15th, 2010, 05:28 PM posted to microsoft.public.access.queries
Jeff Boyce
external usenet poster
 
Posts: 8,621
Default Multiple Tables in Query not Listing Data.

Take a look in Access HELP for the Nz() function. This may allow you to
display, say, a zero when the underlying field is Null.

NOTE: based on the SQL you provided, you are telling Access to ONLY show
you data when ALL the tables having matching records. I suspect you mean to
be asking Access to show you ALL of one table's records, plus ANY matching
records from the other. If so, in the query design view, these join
properties are shown as an arrowhead-line, rather than a simple line.

In the SQL, it shows as a LEFT JOIN (or RIGHT) instead of an INNER JOIN.

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.

"Ty" wrote in message
...
I cannot seem to get this correct. I am trying to run a query on two
databases one of which is linked to the other. I am trying to get the
query
to display a 0 for the total defects counted from one table based on the
date
and time from another table. So far when I run the query I get only the
counts from the values that are not null.

Here is the SQL Statement:

SELECT Pro_Total_by_Cell.Cell, Pro_Total_by_Cell.Shift,
Pro_Total_by_Cell.Time, Pro_Total_by_Cell.ProTotal,
Pro_Total_by_Cell.Time1,
Hourly_Defects_by_Cell3.CountofFC, Control_Limit_by_Cell.UCL,
IIf(IsNull([CountofFC]),"0",[CountofFC]/[ProTotal]) AS [Percent Defective]
FROM TimeCovTable INNER JOIN (Control_Limit_by_Cell INNER JOIN
(Hourly_Defects_by_Cell3 INNER JOIN Pro_Total_by_Cell ON
(Hourly_Defects_by_Cell3.Cell = Pro_Total_by_Cell.Cell) AND
(Hourly_Defects_by_Cell3.Time2 = Pro_Total_by_Cell.Time1)) ON
Control_Limit_by_Cell.Cell = Hourly_Defects_by_Cell3.Cell) ON
(TimeCovTable.TimeID = Pro_Total_by_Cell.Time1) AND (TimeCovTable.Time =
Pro_Total_by_Cell.Time)
GROUP BY Pro_Total_by_Cell.Cell, Pro_Total_by_Cell.Shift,
Pro_Total_by_Cell.Time, Pro_Total_by_Cell.ProTotal,
Pro_Total_by_Cell.Time1,
Hourly_Defects_by_Cell3.CountofFC, Control_Limit_by_Cell.UCL;


Results below.

Cell Shift Time ProTotal Time1 CountofFC UCL Percent Defective
CELL 2 1 8:00 AM 46 8 1 0.045 2.17391304347826E-02



If you need further explanation please let me know.



  #3  
Old March 15th, 2010, 05:36 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Multiple Tables in Query not Listing Data.

If you have nulls then you must use a left or right join.
I did not test this --
SELECT Pro_Total_by_Cell.Cell, Pro_Total_by_Cell.Shift,
Pro_Total_by_Cell.Time, Pro_Total_by_Cell.ProTotal, Pro_Total_by_Cell.Time1,
Hourly_Defects_by_Cell3.CountofFC, Control_Limit_by_Cell.UCL,
IIf(IsNull([CountofFC]),"0",[CountofFC]/[ProTotal]) AS [Percent Defective]
FROM TimeCovTable INNER JOIN (Control_Limit_by_Cell INNER JOIN (
Pro_Total_by_Cell LEFT JOIN Hourly_Defects_by_Cell3 ON
(Hourly_Defects_by_Cell3.Cell = Pro_Total_by_Cell.Cell) AND
(Hourly_Defects_by_Cell3.Time2 = Pro_Total_by_Cell.Time1)) ON
Control_Limit_by_Cell.Cell = Hourly_Defects_by_Cell3.Cell) ON
(TimeCovTable.TimeID = Pro_Total_by_Cell.Time1) AND (TimeCovTable.Time =
Pro_Total_by_Cell.Time)
GROUP BY Pro_Total_by_Cell.Cell, Pro_Total_by_Cell.Shift,
Pro_Total_by_Cell.Time, Pro_Total_by_Cell.ProTotal, Pro_Total_by_Cell.Time1,
Hourly_Defects_by_Cell3.CountofFC, Control_Limit_by_Cell.UCL;

--
Build a little, test a little.


"Ty" wrote:

I cannot seem to get this correct. I am trying to run a query on two
databases one of which is linked to the other. I am trying to get the query
to display a 0 for the total defects counted from one table based on the date
and time from another table. So far when I run the query I get only the
counts from the values that are not null.

Here is the SQL Statement:

SELECT Pro_Total_by_Cell.Cell, Pro_Total_by_Cell.Shift,
Pro_Total_by_Cell.Time, Pro_Total_by_Cell.ProTotal, Pro_Total_by_Cell.Time1,
Hourly_Defects_by_Cell3.CountofFC, Control_Limit_by_Cell.UCL,
IIf(IsNull([CountofFC]),"0",[CountofFC]/[ProTotal]) AS [Percent Defective]
FROM TimeCovTable INNER JOIN (Control_Limit_by_Cell INNER JOIN
(Hourly_Defects_by_Cell3 INNER JOIN Pro_Total_by_Cell ON
(Hourly_Defects_by_Cell3.Cell = Pro_Total_by_Cell.Cell) AND
(Hourly_Defects_by_Cell3.Time2 = Pro_Total_by_Cell.Time1)) ON
Control_Limit_by_Cell.Cell = Hourly_Defects_by_Cell3.Cell) ON
(TimeCovTable.TimeID = Pro_Total_by_Cell.Time1) AND (TimeCovTable.Time =
Pro_Total_by_Cell.Time)
GROUP BY Pro_Total_by_Cell.Cell, Pro_Total_by_Cell.Shift,
Pro_Total_by_Cell.Time, Pro_Total_by_Cell.ProTotal, Pro_Total_by_Cell.Time1,
Hourly_Defects_by_Cell3.CountofFC, Control_Limit_by_Cell.UCL;


Results below.

Cell Shift Time ProTotal Time1 CountofFC UCL Percent Defective
CELL 2 1 8:00 AM 46 8 1 0.045 2.17391304347826E-02



If you need further explanation please let me know.

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 08:11 PM.


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