Finding the last trx (by date) per customer, per transaction type [message #614081] |
Thu, 15 May 2014 23:46  |
 |
HugeOu
Messages: 2 Registered: May 2014 Location: South Africa
|
Junior Member |
|
|
Hi all
Newbie here.
I need to run a query where I can find the latest balance per Customer per Transaction Type. My table structure looks as follows:
- Transaction Type
- Transaction Date (End_of_Call)
- Client ID
- Available Balance (for that particular Transaction Type)
Basically, a client can purchase "airtime bundles" which he can than consume from in different transactions (the transaction type). An example of the data would look as follows:
TRANSACTION_TYPE_UID END_OF_CALL SUBSCRIBER_UID BALANCE
79001 2014/04/26 13:47 606094135 2147483648
79001 2014/04/26 13:51 606094135 4294967296
79001 2014/04/30 16:53 606096826 104857600
79001 2014/04/22 12:49 606104927 524288000
79013 2014/04/10 14:59 798190099 61200812
79013 2014/04/22 14:43 818888488 1888107861
As you can see from the first 2 rows, that particular Subscriber has 2 entries in the table, and I need a script where the output would be the Balance as at 2014/04/26 13:51, which is the last transaction for that subscriber for that transaction type.
I would greatly appreciate it if anyone can assist me with coming up with a query where I can get the latest value, per Subscriber, per Transaction Type
Many thanks,
Hugo
[EDITED by LF: applied [code] tags to preserve formatting]
[Updated on: Thu, 15 May 2014 23:53] by Moderator Report message to a moderator
|
|
|
|
|
|