Hi All,
I have the following tables:
Order (table)
-------------
OrderID OrderDate
O001 10/10/2004
O002 10/11/2004
Status (Table)
--------------
SID OrderID ReferID Date
1 O001 R3 10/10/2004
2 O001 R5 10/10/2004
Refer (Table)
-------------
ReferID ReferName ReferSort
R1 Quot 1
R2 Cancel 2
R3 Workorder 3
R4 Invoice 4
R5 Jobcomplete 5
And so on....
I want to have a query which will retreive the following:
orderID OrderDate StatusID ReferenceName
O001 10/10/2004 2 JobComplete
As you can see For orderID -> O001 , there are two statusID in status table, BUt i need to get the statusID based on the ReferSort.
eg: for orderID O001, R3 and R5 are two ReferID (see in status table), and there ReferSort is 3 and 5 (see in refer table), i need to get the max (ie 5).
Hope i was descriptive. Please if anyone could tell me how to do it, i will be really thankful.
thanks.
I have the following tables:
Order (table)
-------------
OrderID OrderDate
O001 10/10/2004
O002 10/11/2004
Status (Table)
--------------
SID OrderID ReferID Date
1 O001 R3 10/10/2004
2 O001 R5 10/10/2004
Refer (Table)
-------------
ReferID ReferName ReferSort
R1 Quot 1
R2 Cancel 2
R3 Workorder 3
R4 Invoice 4
R5 Jobcomplete 5
And so on....
I want to have a query which will retreive the following:
orderID OrderDate StatusID ReferenceName
O001 10/10/2004 2 JobComplete
As you can see For orderID -> O001 , there are two statusID in status table, BUt i need to get the statusID based on the ReferSort.
eg: for orderID O001, R3 and R5 are two ReferID (see in status table), and there ReferSort is 3 and 5 (see in refer table), i need to get the max (ie 5).
Hope i was descriptive. Please if anyone could tell me how to do it, i will be really thankful.
thanks.