+ -
当前位置:首页 → 问答吧 → 请教一个组合查询的sql语句

请教一个组合查询的sql语句

时间:2011-12-20

来源:互联网

select a.*,b.YfLxMoeny from CkInfo as a left join (Select x_KxPzh,IsNull(Sum(x_LxMoney),0) as YfLxMoeny from CkLxInfo group by x_KxPzh) as b on a.Pzh=b.x_KxPzh

我这样写了以后,只能查询出CkLxInfo表中有的内容,我想无论CkLxInfo表中有无内容,都能显示出Ckinfo表中的全部的内容,如果CkLxinfo表中没有对应的内容,则该列显示为0 。请问要怎么改正这句呢?

作者: yangqi613   发布时间: 2011-12-20

SQL code
select a.*,ISNULL(b.YfLxMoeny ,0) AS YfLxMoeny
from CkInfo as a 
left join (Select x_KxPzh,IsNull(Sum(x_LxMoney),0) as YfLxMoeny 
from CkLxInfo group by x_KxPzh) as b on a.Pzh=b.x_KxPzh

作者: roy_88   发布时间: 2011-12-20

ISNULL(col,0)

作者: fredrickhu   发布时间: 2011-12-20

热门下载

更多