G
Guest
I have query in which I produce the following type of records:
ID TDate LOC ST_DATE END_DATE Support
820 12/7/2007 1 1/25/2008 12/31/2099 no
820 12/7/2007 2 2/22/2008 12/31/2099 no
820 12/7/2007 3 3/21/2008 12/31/2099 no
820 12/7/2007 4 11/30/2007 12/31/2099 Yes
820 12/7/2007 5 3/7/2008 12/31/2099 no
820 12/7/2007 6 12/7/2007 12/31/2099 Yes
ID = customer ID number
TDate = Training Date required
LOC = There is a location assigned to each one of these that coordinates
with the customer's preferred training location.
ST_Date = Available classroom date
Support = The results of an If statement that tells me if we have the
classroom support for the customer's required training date.
The information in the table above tells me that we do not have support for
their first three as well as their fifth preferred training locations but we
do have the classroom support for their fourth and sixth preferred locations.
I'm trying to write a query that will return the first available preferred
training location going in order of 1-6. So in this instance for this
particular training date the fourth location would be returned.
I'd really appreciate if someone could help me work through a statement that
returns this value. My preferred method would be to look at the group of
each customer (6 records for each) and return only the record that is
appropriate.
Another thing I need to consider is that if we do not have any classrooms
available for their TDate than I need to push their TDate to the next
available classroom St_date.
Thanks in advance for anything you can offer.
ID TDate LOC ST_DATE END_DATE Support
820 12/7/2007 1 1/25/2008 12/31/2099 no
820 12/7/2007 2 2/22/2008 12/31/2099 no
820 12/7/2007 3 3/21/2008 12/31/2099 no
820 12/7/2007 4 11/30/2007 12/31/2099 Yes
820 12/7/2007 5 3/7/2008 12/31/2099 no
820 12/7/2007 6 12/7/2007 12/31/2099 Yes
ID = customer ID number
TDate = Training Date required
LOC = There is a location assigned to each one of these that coordinates
with the customer's preferred training location.
ST_Date = Available classroom date
Support = The results of an If statement that tells me if we have the
classroom support for the customer's required training date.
The information in the table above tells me that we do not have support for
their first three as well as their fifth preferred training locations but we
do have the classroom support for their fourth and sixth preferred locations.
I'm trying to write a query that will return the first available preferred
training location going in order of 1-6. So in this instance for this
particular training date the fourth location would be returned.
I'd really appreciate if someone could help me work through a statement that
returns this value. My preferred method would be to look at the group of
each customer (6 records for each) and return only the record that is
appropriate.
Another thing I need to consider is that if we do not have any classrooms
available for their TDate than I need to push their TDate to the next
available classroom St_date.
Thanks in advance for anything you can offer.