日期:2014-05-18 浏览次数:20619 次
--sql 2000 declare @sdate datetime declare @edate datetime set @sdate = '2012-01-01' set @edate = '2012-01-31' select uname = 'nanji' , m.dt , isnull(n.nanji) uno from ( select dateadd(dd,num,@sdate) dt from (select isnull((select count(1) from sysobjects where id<t.id),0) as num from sysobjects t) a where dateadd(dd,num,@sdate)<=@edate ) m left join ( select convert(varchar(10),Ntime,120) dt , sum(Nanji) Nanji from hkb group by convert(varchar(10),Ntime,120) ) n on m.dt = n.dt union all select uname = 'Suzhou' , m.dt , isnull(n.Suzhou) uno from ( select dateadd(dd,num,@sdate) dt from (select isnull((select count(1) from sysobjects where id<t.id),0) as num from sysobjects t) a where dateadd(dd,num,@sdate)<=@edate ) m left join ( select convert(varchar(10),Ntime,120) dt , sum(Suzhou) Suzhou from hkb group by convert(varchar(10),Ntime,120) ) n on m.dt = n.dt
------解决方案--------------------
如需要阅读该回复,请登录或注册CSDN!