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  

Union query with left join



 
 
Thread Tools Display Modes
  #1  
Old April 13th, 2005, 08:27 AM
Abdula Zakaria via AccessMonster.com
external usenet poster
 
Posts: n/a
Default Union query with left join

Hello all and please excuse me for the long post.
I have the following tables in my databases:
[Daily Test Statistics TP],[Daily Test Statistics IV],[Daily Test
Statistics W/S], [fail result],[pass result] with a common field name [Part
No]
I want to have a query which will gives me the number of [Part No] which
are [NG Batch] and [OK Batch] for a given period.
e.g:
[Part No] [NG Batch] [OK Batch]
ABC 2 6
XYZ 1 13

This query works:
SELECT [Daily Test Statistics TP].[Part No], [fail result].[NG Batch],
[pass result].[OK Batch]
FROM ([Daily Test Statistics TP] LEFT JOIN [pass result] ON [Daily Test
Statistics TP].[Part No]=[pass result].[Part No]) LEFT JOIN [fail result]
ON [Daily Test Statistics TP].[Part No]=[fail result].[Part No]
WHERE ((([Daily Test Statistics TP].[Test Date]) Between DateAdd("d",-3-
WeekDay(Date()),Date()) And DateAdd("d",Weekday(Date()),Date())))
GROUP BY [Daily Test Statistics TP].[Part No], [fail result].[NG Batch],
[pass result].[OK Batch];

I don't know how to make the union works for the following please help:
SELECT [Daily Test Statistics TP].[Part No], Count(*) AS [NG Batch]
FROM
[Daily Test Statistics TP]
WHERE ((([Daily Test Statistics TP].[Result])="fail"))
GROUP BY [Daily Test Statistics TP].[Part No]
union
SELECT [Daily Test Statistics IV].[Part No], Count(*) AS [NG Batch]
FROM
[Daily Test Statistics IV]
WHERE ((([Daily Test Statistics IV].[Result])="fail"))
GROUP BY [Daily Test Statistics IV].[Part No]

UNION SELECT [Daily Test Statistics W/S].[Part No], Count(*) AS [NG Batch]
FROM
[Daily Test Statistics W/S]
WHERE ((([Daily Test Statistics W/S].[Result])="fail"))
GROUP BY [Daily Test Statistics W/S].[Part No];

SELECT [Daily Test Statistics TP].[Part No], Count(*) AS [OK Batch]
FROM
[Daily Test Statistics TP]
WHERE ((([Daily Test Statistics TP].[Result])="Pass"))
GROUP BY [Daily Test Statistics TP].[Part No]
union
SELECT [Daily Test Statistics IV].[Part No], Count(*) AS [OK Batch]
FROM
[Daily Test Statistics IV]
WHERE ((([Daily Test Statistics IV].[Result])="Pass"))
GROUP BY [Daily Test Statistics IV].[Part No]

UNION SELECT [Daily Test Statistics W/S].[Part No], Count(*) AS [OK Batch]
FROM
[Daily Test Statistics W/S]
WHERE ((([Daily Test Statistics W/S].[Result])="Pass"))
GROUP BY [Daily Test Statistics W/S].[Part No];

With many thanks for your time .
Zaky.

--
Message posted via http://www.accessmonster.com
  #2  
Old April 13th, 2005, 09:37 AM
Abdula Zakaria via AccessMonster.com
external usenet poster
 
Posts: n/a
Default

Problem solved.
I created a new query containing all the [part no] from the 3 tables and
then make the left join queries.

--
Message posted via http://www.accessmonster.com
  #3  
Old April 13th, 2005, 03:13 PM
KT
external usenet poster
 
Posts: n/a
Default

Test


  #4  
Old April 23rd, 2005, 09:21 AM
Mathsidiot
external usenet poster
 
Posts: n/a
Default

x with a line over it,, to dednote "mean of a sample".

Anyone kindly tell me how to do this?

  #5  
Old April 23rd, 2005, 11:58 AM
Douglas J. Steele
external usenet poster
 
Posts: n/a
Default

In Access? You can't, unless you're using an RTF control.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)



"Mathsidiot" wrote in message
...
x with a line over it,, to dednote "mean of a sample".

Anyone kindly tell me how to do this?



 




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

Similar Threads
Thread Thread Starter Forum Replies Last Post
#Error in result set with query containing table and left join to another query bu General Discussion 0 April 6th, 2005 09:48 PM
Nested in-line Query laura Running & Setting Up Queries 0 February 11th, 2005 12:17 AM
Union query is displaying Chinese characters for one of the fields Seth Schwarm Running & Setting Up Queries 4 January 27th, 2005 04:26 PM
Union Query Not Returning A Value Jeff G Running & Setting Up Queries 2 October 19th, 2004 05:47 PM
Joining 2 Left Join Queries esi Running & Setting Up Queries 2 September 16th, 2004 08:16 PM


All times are GMT +1. The time now is 01:51 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.