BobRoyAce
2012-08-14 03:54:32 UTC
Let's say that I have the following table:
TRXS
-------
TRX_ID
CA_ID
TRX_DATE
TRXS can have multiple records with the same CA_ID. Within the multiple records for a given CA_ID, there could be many different values for TRX_DATE. For example:
TRX_ID, CA_ID, TRX_DATE
1,1,1/3/12
2,1,1/5/12
3,1,1/10/12
4,1,2/4/12
5,1,2/3/12
As you can see, there are five records for CA_ID of 1. What I want is a query that will return the TRX_ID of the record that has the MAX(TRX_DATE) for CA_ID of 1. In the above case, the query would return a value of 4, since that record has a TRX_DATE of 2/4/12, representing the MAX value.
How can I construct a query like this?
NOTE: This question is similar to, but different from, another question that I posted to this group earlier.
TRXS
-------
TRX_ID
CA_ID
TRX_DATE
TRXS can have multiple records with the same CA_ID. Within the multiple records for a given CA_ID, there could be many different values for TRX_DATE. For example:
TRX_ID, CA_ID, TRX_DATE
1,1,1/3/12
2,1,1/5/12
3,1,1/10/12
4,1,2/4/12
5,1,2/3/12
As you can see, there are five records for CA_ID of 1. What I want is a query that will return the TRX_ID of the record that has the MAX(TRX_DATE) for CA_ID of 1. In the above case, the query would return a value of 4, since that record has a TRX_DATE of 2/4/12, representing the MAX value.
How can I construct a query like this?
NOTE: This question is similar to, but different from, another question that I posted to this group earlier.