加入两个表的复杂Sql查询

时间:2012-05-22 16:19:17

标签: sql sql-server-2005

我有两张桌子并想要结果日期和银行明智。实施例如下。

Table1: Name:- AccountMast                      
companyID   A/CID   Name          BalDR BalCR   
102         14      SHOBHA        NULL  NULL    
102         15      SONKI         NULL  NULL    
102         16      BANK OF INDIA null  12000       

Table2 Name :- DeBank                       
companyID   transID  date        name          particulars  deposit withdrawal
102         2        12/04/2012  BANK OF INDIA MAHENDRA     1000    NULL
102         4        15/04/2012  CENTRAL BANK  MAHENDRA     1000    NULL
102         3        20/05/2012  BANK OF INDIA MAHENDRA     2000    NULL


Result                      
BANK WISE RESULT BANK OF INDIA              
date        transID particulars deposit withdrawal  BALANCE 
01/04/2012          BAL B/F                         12000   
12/04/2012    2     MAHENDRA    1000    NULL        13000 
20/05/2012    3     MAHENDRA    2000    NULL        15000


BANK WISE RESULT CENTRAL BANK OF INDIA              
date        transID particulars deposit withdrawal  BALANCE**   
01/04/2012          BAL B/F             
15/04/2012   4      MAHENDRA    2000    NULL        2000

那么它的sql语句是什么?。

0 个答案:

没有答案