Database Management
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDatabase Management

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now!
  #1  
Old January 28th, 2003, 02:49 PM
atarbaer atarbaer is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 17 atarbaer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Identify missing data

I have a Microsoft Access 97 table with two fields, Date and Site. Data is reported to me on a daily basis from each of five sites. I would like to create a query which identifies which sites did not report data on any given day. For example:

Date Site
1-28-2003 A
1-28-2003 B
1-28-2003 C
1-28-2003 D
1-28-2003 E
1-27-2003 A
1-27-2003 B
1-27-2003 C
1-27-2003 D
1-27-2003 E
1-26-2003 A
1-26-2003 B
1-26-2003 D
1-26-2003 E
1-25-2003 A
1-25-2003 B
1-25-2003 C
1-25-2003 D
1-25-2003 E

... and so on

I would like the query to report that on 1-26-2003, site C did not report data to me.

Is there some simple way to do this...? Thanks in advance for your help.

Reply With Quote
  #2  
Old January 28th, 2003, 03:20 PM
NoXcuz's Avatar
NoXcuz NoXcuz is offline
Wiking
Dev Shed Expert (3500 - 3999 posts)
 
Join Date: Sep 2000
Location: Sweden
Posts: 3,608 NoXcuz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 h 49 m 27 sec
Reputation Power: 11
A combination of SQL/english:
You would need a list of dates that you left joined with the other table using Date where Site is null.

So there's no easy way unless using some calendar stuff in Access...

//NoXcuz
__________________
UN*X is sexy!
who | grep -i blonde | date; cd ~; unzip; touch; strip; finger; mount; gasp; yes; uptime; umount; sleep

Reply With Quote
  #3  
Old January 29th, 2003, 08:29 AM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
If you are asking what I think you are then here is one way you can approach this:

Create a table that holds the site locations
sitelocations table
-----------------------
A
B
C
D
E
.....

In conjunction with the existing table and the fact that you can perform subqueries in Access the following SQL will get you the sites that did not report for a given day:

SELECT t1.field1
FROM table1 t1
LEFT OUTER JOIN table2 t2
ON t1.field1 = t2.field2
WHERE t1.field1 NOT IN (SELECT field2 FROM table2 where field1 = #2003-01-03#)
;

Let me know if you need more help or if this was not what you were looking for.
__________________
El éxito consiste en una serie de pequeñas victorias día a día

MySQL, MS SQL, MS ACCESS, Oracle Database Manager - http://victorpendleton.net/products/psdviewer.html

Reply With Quote
  #4  
Old January 29th, 2003, 01:25 PM
sforrester sforrester is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2002
Posts: 5 sforrester User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The table is normalized. The ‘Date’ column can be given a primary key constraint, since each date attribute is unique. The non-key column ‘Site’ is dependent on the ‘Date’ column. Therefore the original table should suffice.
Next step is to answer the question posed in a proposition form, something like:
A REPORT (the entity name possibly) was generated on ‘Date’ (date_value) by ‘Site’ (site_value), where Date and Site are column names (predicates of the proposition to be exact).

So in pseudo-SQL, the query would appear as:

Select Site
From REPORT
Where Date = (date_value)

-- to return all Sites for that particular date

or

Select Site
From REPORT
Where Date = (date_value)
And
Site = (site_value)

-- to return a particular site value for a particular day. If no rows returned then there is no report from the site for the day

Please let me know if I am missing anything.

Regards,
Sean

Reply With Quote
  #5  
Old January 29th, 2003, 04:30 PM
atarbaer atarbaer is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 17 atarbaer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Identify missing data: Clarification

Thank you all for your suggestions. I'm a beginner with Access and SQL, so I need a little extra help interpreting your solutions. I think I need to clarify: The dates in the existing table (with fields <date> and <site>) go back to 1999. Each of the 12 sites is supposed to report data on a daily basis. I would like to generate a report which lists all the dates on which particular sites did not report data -- if I had a limited number of dates, I could run a query separately for each date or site, but in this case I have several years' worth of data so that approach doesn't seem practical. Thanks again for your help.

Reply With Quote
  #6  
Old January 31st, 2003, 12:48 AM
victorpendleton victorpendleton is offline
Contributing User
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jan 2003
Location: No es importante
Posts: 2,065 victorpendleton User rank is Private First Class (20 - 50 Reputation Level)victorpendleton User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 6 h 31 m 56 sec
Reputation Power: 8
Why not run the report based on sites since it seems from your test data that the number of sites is fairly small. So instead of date being your search criteria change that to siteID.

Reply With Quote
  #7  
Old January 31st, 2003, 11:48 AM
atarbaer atarbaer is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2000
Posts: 17 atarbaer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks again for your responses. I ended up doing something similar to what NoXcuz suggested, separately for each site.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDatabase Management > Identify missing data


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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 On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway