MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

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:
  #1  
Old July 26th, 2004, 01:22 PM
comp974 comp974 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2004
Posts: 3 comp974 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Information Consolidation

Currently I have this type of Table

Number - Number - Date - Date
Renter - Equipment - From - Through

The information is entered on a weekly basis, the renter can have a piece of equipment for 1 to 4 weeks, not neccessarily consequtively.

I am trying to make an Access SQL statement that will consolidate the information to pertain to the when they first got it and when they last used it. For instance

Renter A - Equipment A - 6/1/04 - 6/15/04
Renter A - Equipment B - 6/15/04 - 6/30/04
Renter A - Equipment C - 6/1/04 - 6/30/04
Renter B - Equipment B - 6/1/04 - 6/15/04
Renter B - Equipment A - 6/15/04 - 6/30/04
Renter B - Equipment D - 6/1/04 - 6/8/04
Renter B - Equipment D - 6/15/04 - 6/21/04

and so on... any help, I originally thought something like subqueries, but happiness didn't abound, Records abounded.

SELECT EquippedPatient.PatientID,
EquippedPatient.EquipmentID,
EquippedPatient.From,
(
SELECT E4.Through
FROM EquippedPatient,
EquippedPatient as E2,
EquippedPatient as E3,
EquippedPatient as E4
WHERE
(
((E2.PatientID=E3.PatientID) AND
(E2.EquipmentID=E3.EquipmentID) AND
(E2.ID<E3.ID))
)
AND
(
((E3.PatientID=E4.PatientID) AND
(E3.EquipmentID=E4.EquipmentID) AND
(E3.ID<E4.ID))
)
) AS Through
FROM EquippedPatient, EquippedPatient as E1
WHERE
((EquippedPatient.PatientID=E1.PatientID)AND
(EquippedPatient.EquipmentID=E1.EquipmentID) AND
(EquippedPatient.Through=E1.From) AND
(EquippedPatient.ID<E1.ID)
)
ORDER BY EquippedPatient.PatientID


Complex I know, but any help would be appreciated, even if you tell me it can't be done .

Thank You
Eric F.

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > Information Consolidation


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 3 hosted by Hostway