各位大侠们,下面这条oracle语句怎么转换成sqlserver的?
a(branch,func)
b(dig,times)
select a.func,sum(b.times) from a,b
where b.dig in a.branch
group by a.func写成这样的结果不对
select a.func,sum(b.times) from a,b
where b.dig in (select branch from a)
group by a.func

解决方案 »

  1.   

    orcale 不太会 不知道是不是这个意思select a.func,sum(b.times) 
    from b inner join a on a.branch=b.dig
    group by a.func 
      

  2.   


    试试这个:
    select a.func,sum(b.times) from a,b 
    where charindex(b.dig ,a.branch) > 0
    group by a.func select a.func,sum(b.times) from a,b 
    where a.branch like '%' + b.dig + '%'
    group by a.func 
    不过,即使在oracle中,你的写法也不对.最好给出完整的表结构,测试数据,计算方法和正确结果.发帖注意事项
    http://topic.csdn.net/u/20091130/21/fb718680-98ff-4afb-98d8-cff2f8293ed5.html?24281
      

  3.   


    a 表中的branch 与b表中的dig type一样?
      

  4.   

    a 表中的branch 与b表中的dig type一样?
     一样 就你写的也是对的。