日期:2014-05-17 浏览次数:20502 次
select a.id,a.name,a.type,b.今日发送,b.今日回收,b.今日结余,a.昨日累计结余
from table2 a left join table1 b on a.id=b.id
create table hzk(id varchar(20),name nvarchar(30),type int,jrfs int,jrhs int,jrjy int)
insert into hzk
select '100001',N'天津佰润-天津',1000,1,0,-1
create table mxk(id varchar(20),name nvarchar(30),type int,zrljjy int)
insert into mxk
select '100001',N'天津佰润-天津',null,-1
union
select '100001',N'天津佰润-天津',1000,-1
union
select '100001',N'天津佰润-天津',800,1
select a.id,a.name,a.type,今日发送=isnull(b.jrfs,0),今日回收=isnull(b.jrhs,0) ,
isnull(jrjy,0) as 今日结余,a.zrljjy 昨日累计结余 from mxk a left join hzk b
on a.type=b.type