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  

"negative" query



 
 
Thread Tools Display Modes
  #1  
Old August 3rd, 2009, 02:58 PM posted to microsoft.public.access.queries
stephanie
external usenet poster
 
Posts: 375
Default "negative" query

Hi. I'm trying to find all the locations that did NOT have incidents
reported. All I can seem to bring back is those locations that did report
incidents. I even branched out and tried a RIGHT join! I'd appreciate your
suggestions. Thanks!

SELECT DISTINCT tbOffices.Location
FROM qu_tbIncidents_Final_Ops_Completed_012 RIGHT JOIN tbOffices ON
qu_tbIncidents_Final_Ops_Completed_012.Location = tbOffices.Location
WHERE (((tbOffices.Location)=
[qu_tbIncidents_Final_Ops_Completed_012].[Location]) AND
((qu_tbIncidents_Final_Ops_Completed_012.[Discovery Date]) Between
CVDate([forms]![frquick]![StartDate]) And
CVDate([forms]![frquick]![EndDate])));

  #2  
Old August 3rd, 2009, 03:31 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default "negative" query

Try this --
SELECT DISTINCT tbOffices.Location
FROM tbOffices LEFT JOIN qu_tbIncidents_Final_Ops_Completed_012 ON
qu_tbIncidents_Final_Ops_Completed_012.Location = tbOffices.Location
WHERE ([qu_tbIncidents_Final_Ops_Completed_012].[Location] Is Null) AND
((qu_tbIncidents_Final_Ops_Completed_012.[Discovery Date]) Between
CVDate([forms]![frquick]![StartDate]) And
CVDate([forms]![frquick]![EndDate]));

--
Build a little, test a little.


"Stephanie" wrote:

Hi. I'm trying to find all the locations that did NOT have incidents
reported. All I can seem to bring back is those locations that did report
incidents. I even branched out and tried a RIGHT join! I'd appreciate your
suggestions. Thanks!

SELECT DISTINCT tbOffices.Location
FROM qu_tbIncidents_Final_Ops_Completed_012 RIGHT JOIN tbOffices ON
qu_tbIncidents_Final_Ops_Completed_012.Location = tbOffices.Location
WHERE (((tbOffices.Location)=
[qu_tbIncidents_Final_Ops_Completed_012].[Location]) AND
((qu_tbIncidents_Final_Ops_Completed_012.[Discovery Date]) Between
CVDate([forms]![frquick]![StartDate]) And
CVDate([forms]![frquick]![EndDate])));

  #3  
Old August 3rd, 2009, 03:42 PM posted to microsoft.public.access.queries
stephanie
external usenet poster
 
Posts: 375
Default "negative" query

Thanks. That didn't quite do it.

Here's the setup: tbIncidents_Final_Ops_Completed_012 contains all of the
pertinent incidents. This query also lists the locations where the incidents
did occurr.

tbOffices contains all of the locations that incidents COULD occur. So I'm
trying to determine which location (from tbOffices) does not have an
incident, i.e. does not appear in tbIncidents_Final_Ops_Completed_012.

Hope that explains it. Any suggestion? Thanks!

"KARL DEWEY" wrote:

Try this --
SELECT DISTINCT tbOffices.Location
FROM tbOffices LEFT JOIN qu_tbIncidents_Final_Ops_Completed_012 ON
qu_tbIncidents_Final_Ops_Completed_012.Location = tbOffices.Location
WHERE ([qu_tbIncidents_Final_Ops_Completed_012].[Location] Is Null) AND
((qu_tbIncidents_Final_Ops_Completed_012.[Discovery Date]) Between
CVDate([forms]![frquick]![StartDate]) And
CVDate([forms]![frquick]![EndDate]));

--
Build a little, test a little.


"Stephanie" wrote:

Hi. I'm trying to find all the locations that did NOT have incidents
reported. All I can seem to bring back is those locations that did report
incidents. I even branched out and tried a RIGHT join! I'd appreciate your
suggestions. Thanks!

SELECT DISTINCT tbOffices.Location
FROM qu_tbIncidents_Final_Ops_Completed_012 RIGHT JOIN tbOffices ON
qu_tbIncidents_Final_Ops_Completed_012.Location = tbOffices.Location
WHERE (((tbOffices.Location)=
[qu_tbIncidents_Final_Ops_Completed_012].[Location]) AND
((qu_tbIncidents_Final_Ops_Completed_012.[Discovery Date]) Between
CVDate([forms]![frquick]![StartDate]) And
CVDate([forms]![frquick]![EndDate])));

  #4  
Old August 3rd, 2009, 03:51 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default "negative" query

That didn't quite do it.
What did you not get that you were expecting? What did you get that you
should not have gotten?
Saying something is not quite right provides no explaination of what is wrong.
--
Build a little, test a little.


"Stephanie" wrote:

Thanks. That didn't quite do it.

Here's the setup: tbIncidents_Final_Ops_Completed_012 contains all of the
pertinent incidents. This query also lists the locations where the incidents
did occurr.

tbOffices contains all of the locations that incidents COULD occur. So I'm
trying to determine which location (from tbOffices) does not have an
incident, i.e. does not appear in tbIncidents_Final_Ops_Completed_012.

Hope that explains it. Any suggestion? Thanks!

"KARL DEWEY" wrote:

Try this --
SELECT DISTINCT tbOffices.Location
FROM tbOffices LEFT JOIN qu_tbIncidents_Final_Ops_Completed_012 ON
qu_tbIncidents_Final_Ops_Completed_012.Location = tbOffices.Location
WHERE ([qu_tbIncidents_Final_Ops_Completed_012].[Location] Is Null) AND
((qu_tbIncidents_Final_Ops_Completed_012.[Discovery Date]) Between
CVDate([forms]![frquick]![StartDate]) And
CVDate([forms]![frquick]![EndDate]));

--
Build a little, test a little.


"Stephanie" wrote:

Hi. I'm trying to find all the locations that did NOT have incidents
reported. All I can seem to bring back is those locations that did report
incidents. I even branched out and tried a RIGHT join! I'd appreciate your
suggestions. Thanks!

SELECT DISTINCT tbOffices.Location
FROM qu_tbIncidents_Final_Ops_Completed_012 RIGHT JOIN tbOffices ON
qu_tbIncidents_Final_Ops_Completed_012.Location = tbOffices.Location
WHERE (((tbOffices.Location)=
[qu_tbIncidents_Final_Ops_Completed_012].[Location]) AND
((qu_tbIncidents_Final_Ops_Completed_012.[Discovery Date]) Between
CVDate([forms]![frquick]![StartDate]) And
CVDate([forms]![frquick]![EndDate])));

  #5  
Old August 3rd, 2009, 04:08 PM posted to microsoft.public.access.queries
stephanie
external usenet poster
 
Posts: 375
Default "negative" query

This query brought back nothing as the location of an incident isn't null- if
an incident occurred, there is a listed location (all of that information is
contained in tbIncidents_Final_Ops_Completed_012

I'm trying to compare that information against tbOffices, which lists ALL
locations and trying to determine which locations (tbOffices) did not have an
incident listed in tbIncidents_Final_Ops_Completed_012

Thanks for your time!


"KARL DEWEY" wrote:

That didn't quite do it.

What did you not get that you were expecting? What did you get that you
should not have gotten?
Saying something is not quite right provides no explaination of what is wrong.
--
Build a little, test a little.


"Stephanie" wrote:

Thanks. That didn't quite do it.

Here's the setup: tbIncidents_Final_Ops_Completed_012 contains all of the
pertinent incidents. This query also lists the locations where the incidents
did occurr.

tbOffices contains all of the locations that incidents COULD occur. So I'm
trying to determine which location (from tbOffices) does not have an
incident, i.e. does not appear in tbIncidents_Final_Ops_Completed_012.

Hope that explains it. Any suggestion? Thanks!

"KARL DEWEY" wrote:

Try this --
SELECT DISTINCT tbOffices.Location
FROM tbOffices LEFT JOIN qu_tbIncidents_Final_Ops_Completed_012 ON
qu_tbIncidents_Final_Ops_Completed_012.Location = tbOffices.Location
WHERE ([qu_tbIncidents_Final_Ops_Completed_012].[Location] Is Null) AND
((qu_tbIncidents_Final_Ops_Completed_012.[Discovery Date]) Between
CVDate([forms]![frquick]![StartDate]) And
CVDate([forms]![frquick]![EndDate]));

--
Build a little, test a little.


"Stephanie" wrote:

Hi. I'm trying to find all the locations that did NOT have incidents
reported. All I can seem to bring back is those locations that did report
incidents. I even branched out and tried a RIGHT join! I'd appreciate your
suggestions. Thanks!

SELECT DISTINCT tbOffices.Location
FROM qu_tbIncidents_Final_Ops_Completed_012 RIGHT JOIN tbOffices ON
qu_tbIncidents_Final_Ops_Completed_012.Location = tbOffices.Location
WHERE (((tbOffices.Location)=
[qu_tbIncidents_Final_Ops_Completed_012].[Location]) AND
((qu_tbIncidents_Final_Ops_Completed_012.[Discovery Date]) Between
CVDate([forms]![frquick]![StartDate]) And
CVDate([forms]![frquick]![EndDate])));

  #6  
Old August 3rd, 2009, 04:18 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default "negative" query

The query will return location for which has no incident location.
Try entering a new location in tbOffices and run the query. You should get
that new location as a result because there are no incidents assoicated with
it.

--
Build a little, test a little.


"Stephanie" wrote:

This query brought back nothing as the location of an incident isn't null- if
an incident occurred, there is a listed location (all of that information is
contained in tbIncidents_Final_Ops_Completed_012

I'm trying to compare that information against tbOffices, which lists ALL
locations and trying to determine which locations (tbOffices) did not have an
incident listed in tbIncidents_Final_Ops_Completed_012

Thanks for your time!


"KARL DEWEY" wrote:

That didn't quite do it.

What did you not get that you were expecting? What did you get that you
should not have gotten?
Saying something is not quite right provides no explaination of what is wrong.
--
Build a little, test a little.


"Stephanie" wrote:

Thanks. That didn't quite do it.

Here's the setup: tbIncidents_Final_Ops_Completed_012 contains all of the
pertinent incidents. This query also lists the locations where the incidents
did occurr.

tbOffices contains all of the locations that incidents COULD occur. So I'm
trying to determine which location (from tbOffices) does not have an
incident, i.e. does not appear in tbIncidents_Final_Ops_Completed_012.

Hope that explains it. Any suggestion? Thanks!

"KARL DEWEY" wrote:

Try this --
SELECT DISTINCT tbOffices.Location
FROM tbOffices LEFT JOIN qu_tbIncidents_Final_Ops_Completed_012 ON
qu_tbIncidents_Final_Ops_Completed_012.Location = tbOffices.Location
WHERE ([qu_tbIncidents_Final_Ops_Completed_012].[Location] Is Null) AND
((qu_tbIncidents_Final_Ops_Completed_012.[Discovery Date]) Between
CVDate([forms]![frquick]![StartDate]) And
CVDate([forms]![frquick]![EndDate]));

--
Build a little, test a little.


"Stephanie" wrote:

Hi. I'm trying to find all the locations that did NOT have incidents
reported. All I can seem to bring back is those locations that did report
incidents. I even branched out and tried a RIGHT join! I'd appreciate your
suggestions. Thanks!

SELECT DISTINCT tbOffices.Location
FROM qu_tbIncidents_Final_Ops_Completed_012 RIGHT JOIN tbOffices ON
qu_tbIncidents_Final_Ops_Completed_012.Location = tbOffices.Location
WHERE (((tbOffices.Location)=
[qu_tbIncidents_Final_Ops_Completed_012].[Location]) AND
((qu_tbIncidents_Final_Ops_Completed_012.[Discovery Date]) Between
CVDate([forms]![frquick]![StartDate]) And
CVDate([forms]![frquick]![EndDate])));

 




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 04:03 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.