现在有两个表A,BA表:从其他表中查询出的结果集
num_of_deal       num_of_client        Assets           year
    7                  9                3000            2007B表:一个常量表
newdeals          newclients           Assets           year
    5                  6                1000            2007
    19                 21               4000            2008现在要得这样的结果
num_of_deal       num_of_client        Assets           year
    2                  3                2000            2007

解决方案 »

  1.   

    select a.num_of_deal-b.num_of_deal num_of_deal, a.num_of_client - b.num_of_client num_of_client,a.Assets - b.Assets Assets , a.year
    from a,b
    where a.num_of_deal>b.num_of_deal and a.num_of_client > b.num_of_client
      

  2.   

    不是这个意思啊 dawugui 兄~  我是要用A表减去B表中 年份为2007 的那一系列数  而且不想用子查询  受累帮忙 谢谢
      

  3.   

    select a.num_of_deal-b.num_of_deal num_of_deal, a.num_of_client - b.num_of_client num_of_client,a.Assets - b.Assets Assets , a.year
    from a,b
    where b.year = 2007
      

  4.   

    --这不是子查询,是两表连接.
    create table A(num_of_deal int,num_of_client int,Assets int,[year] int)
    insert into A values(7,9,3000,2007)
    create table B(num_of_deal int,num_of_client int,Assets int,[year] int)
    insert into B values(5 ,6 ,1000,2007) 
    insert into B values(19,21,4000,2008)
    goselect a.num_of_deal-b.num_of_deal num_of_deal, a.num_of_client - b.num_of_client num_of_client,a.Assets - b.Assets Assets , b.[year]
    from a,b
    where b.[year] = 2007drop table A,b/*
    num_of_deal num_of_client Assets      year        
    ----------- ------------- ----------- ----------- 
    2           3             2000        2007(所影响的行数为 1 行)
    */