mysql - SQL combine 3 query by using same table -


i have 3 queries shared same table, query 1 below:

select max(trandate) maxdate tbltransaction accno = 12345 

after max transaction date of account 12345, want use max date find max transaction id in query 2 below:

select max(transactionid) maxtran tbltransaction accno = 12345     , trandate = 'pass max tran date here' 

after that, want pass max transaction id in query 2 query 3 below:

select commission tbltransaction accno = 12345     , transactionid = 'pass max tranid here' 

how combine these 3 queries? thanks

assuming tbltransaction has transactionid primary key, can use simpler, mysql:

select commission tbltransaction accno = 12345 order trandate desc,          transactionid desc  limit 1 ; 

and sql-server:

select top (1) commission tbltransaction accno = 12345 order trandate desc,          transactionid desc ; 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -