I try to view latest date and amount from history table for each branch (branch table :viscawangan).
But accouter problem to view amount value.
SELECT b.kod_cawangan,b.nama_cawangan, MAX( a.tkh_data ) AS tarikh_data,[B]a.amount[/B] FROM history a, viscawangan b WHERE a.kod_caw = b.kod_cawangan GROUP BY kod_caw
Here i give example for amount value that suppose to show with branch kod_caw as 'A2'.
If i run below query, it will show all amount for branch code A2.So amount value that suppose to view for branch A2 is 720 which is last record from below query statement.Please refer image as attach for record viewing
SELECT amount FROM history WHERE kod_caw = 'A2'
I'm thinking to select last record from above selection query to handle this problem. But still stuck until now and dont know how. I try to use this example
SELECT * FROM users ORDER BY userid DESC LIMIT 1
but it is for last record of table not last record of query selection.
Hope anyone can give an idea or helps.
Really much appreciate for the respond.
Thanks in advance
For table record can download in here
Edited by red_ruewei: n/a