Pls help me to write an interesting SQL query [message #399993] |
Fri, 24 April 2009 19:25  |
liquidcrystal
Messages: 2 Registered: April 2009
|
Junior Member |
|
|
Hi All,
I have a scenario...
Table A - current table with 3 fields
no dt balance
Table A_hist history table with 3 fields
no dt balance
Table B account code table with 3 fields
no dt cd
Table A is current table which holds 1 record for account with the account closed date
No Dt Balance
10 4/23/2009 0
20 4/24/2009 0
30 4/24/2009 0
Table A_hist is history table with account balance changes with dates
No Dt Balance
10 4/1/2009 2345
20 3/2/2009 1009
30 2/1/2009 879
30 4/22/2009 2500
20 1/31/2009 16000
20 4/15/2009 50
20 3/27/2009 18000
20 2/2/2009 111
10 2/27/2009 654
10 4/19/2009 2000
Table B is a table which holds account codes history
No Dt Cd
10 4/1/2009 aa
20 3/2/2009 bb
30 2/1/2009 cc
30 4/22/2009 cc1
20 1/31/2009 bb1
20 4/15/2009 bb2
20 3/27/2009 bb3
20 2/2/2009 bb4
10 2/27/2009 aa1
10 4/19/2009 aa2
20 4/24/2009 bbfinal
10 4/23/2009 aafinal
30 4/24/2009 ccfinal
Now I want account number with closing date, balance from before closing date and codes from closing date
No DT bal cd
10 4/23/2009 2000 aafinal
20 4/24/2009 50 bbfinal
30 4/24/2009 2500 ccfinal
Please help me out...Many thanks in advance
|
|
|
|
|
|