Question
Query help
I need to query a transaction table to get the last
transaction for each ticket number. Normally, I would just do
somthing like select max(txn_id) as current_txn where ticket_no =
'#form.ticket_not#' (txn_id will link to the master table to get
the actual txn name,ie sales, return, etc.)
Howver, they changed the requirments in obtaining the last transcation.
The last transaction is 1 if max(txn_id) = 1
else
The last transaction is 2 if max(txn_id) = 2 or (max(txn_id) = 4 and max(code) = 1)
else
The last transaction is 3 if max(txn_id) = 3 or (max(txn_id) = 4 and max(code) = 1)
else
The last transaction si 4 if max(txn_id) = 4 and max(code)=0
else
The last transactions is 5 if the txn_id = 5 and code=0 (no max used on this one)
else
The last transaction is 7 if txn_id = 7 and code = 0 (no max used on this one)
else
The last transaction is 6 if (txn_id = 6 and (txn_id <> 5 and code=0) or (txn_id<>7 and code=0))
How do I write the query based on the above requirements, to get the last transaction for a ticket number ?
Howver, they changed the requirments in obtaining the last transcation.
The last transaction is 1 if max(txn_id) = 1
else
The last transaction is 2 if max(txn_id) = 2 or (max(txn_id) = 4 and max(code) = 1)
else
The last transaction is 3 if max(txn_id) = 3 or (max(txn_id) = 4 and max(code) = 1)
else
The last transaction si 4 if max(txn_id) = 4 and max(code)=0
else
The last transactions is 5 if the txn_id = 5 and code=0 (no max used on this one)
else
The last transaction is 7 if txn_id = 7 and code = 0 (no max used on this one)
else
The last transaction is 6 if (txn_id = 6 and (txn_id <> 5 and code=0) or (txn_id<>7 and code=0))
How do I write the query based on the above requirements, to get the last transaction for a ticket number ?
