Advertisement

06.16.2008 at 05:09AM PDT, ID: 23487828
[x]
Attachment Details

SQl query, Aceesing records by using a filter based on previous entries.

Asked by richecker in MS SQL Server, SQL Reporting, SQL Server 2005

I am writing a report for the local sheriffs office here and I am trying to find a way to show evidence items that have been returned from FDLE agencies. Here is what a sample set of the table looks like.
I would do a join onto the item detail table to get more information about it but this is the only table that I need help in working this out:

Item number:      Transaction Code:      Transaction Date:
1                     FDLE checkout            6/05/08
2                      LAB checkout            6/05/08
1                      CHECKIN               6/07/08
2                      CHECKIN               6/07/08
1                      DNA LAB              6/09/08
1                      CHECKIN              06/10/08

Now what I need to do is to figure out what items have been checked in on a particular day that were last checked out to FDLE. For instance: If I was running the report on 6/07/08 I would see only Item 1 on my report since its last transaction was an FDLE checkout and it was checked in on the day that I had specified. Item 2 would not show up since it was not checked out to FDLE. Now if I run the report for 06/10/08, nothing should come up in my report since Item 1 was out to the DNA lab on its last transaction and not the FDLE. But how do I narrow that down?
This is where I have the trouble, I can narrow down which items were checked out to FDLE and I can narrow down which items were marked checked in and I could even do a left outer join from FDLE to the checkin result and if there was a field populated in the checkin side it would show me if the item was a. sent out to fdle and b. if it got checked in. However since items can have multiple transactions and could have been checked out on a different transaction yet still show a checkin date for the day that I am running the report, I do not know how to handle that. Any help is greatly appreciated.
Start Free Trial
 
 
[+][-]06.16.2008 at 07:12AM PDT, ID: 21793759

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.16.2008 at 07:13AM PDT, ID: 21793772

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]06.16.2008 at 07:30AM PDT, ID: 21793941

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]06.16.2008 at 09:04AM PDT, ID: 21794911

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MS SQL Server, SQL Reporting, SQL Server 2005
Sign Up Now!
Solution Provided By: RWrigley
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628