|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Shed Forums > Databases > MS SQL Development > Information Consolidation |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|