Query:Earliest DeliveryDate

Rattlesnake

Well-known member
Joined
Dec 23, 2003
Messages
47
Hi ,
In Sql Server 2000 I have a Log table "Logs" that conatins the fields
1. OrderNo
2. SequenceID


There is another table "Sequences" , that has the fields
1. SequenceID
2. DeliveryDate

In the Log table there can be multiple records for an Order with different SequenceID.
e.g.

OrderNo : SequenceID
_______ :___________
1 : 5
1 : 10
1 : 15
2 : 6
3 : 11
3 : 18

And the Sequences table is e.g.

SequenceID : DeliveryDate
__________ : ____________
5 : 02/01/2007
6 : 02/05/2007
10 : 02/10/2007
11 : 02/12/2007
15 : 02/13/2007
18 : 02/16/2007



Now each SequenceID corresponds to a DeliveryDate from the Sequences tabele


I want to create a query that will give me the Min(DeliveryDate) for each Order along with the corresponding SeqeunceID

So basically I want to know the earliest delivery date for an Order and the SequenceID to which this earliest delivery date corresponds to.


What will be the Query for this ???

Thanks
 
Back
Top