CREATE PROCEDURE REPORT_COUNT3
(@start_datem nvarchar(20),
@end_datem nvarchar(20) )
AS
select '統計(總)' as 統計, sum(d1.ps) as ps,sum(d1.weig) as weig,sum(d1.charge) as charge from (select d.c3,sum(d.ps) as ps,sum(d.weig) as weig,sum(d.charge) as charge from (select case when m.loc_code is null then s.stano else m.loc_code end as loc_code,s.station,s.c3,
isnull(m.ps,0) as ps,isnull(m.weig,0) as weig,isnull(m.charge,0) as charge from
(select loc_code,count(*) as ps,sum(weig) as weig,sum(charge) as charge from manifest where datem between @start_datem and @end_datem group by loc_code) m full outer join stat s on m.loc_code=s.stano) d group by c3) d1
GO各位帮忙看一下,有那里需要改进的地方,TKS
(@start_datem nvarchar(20),
@end_datem nvarchar(20) )
AS
select '統計(總)' as 統計, sum(d1.ps) as ps,sum(d1.weig) as weig,sum(d1.charge) as charge from (select d.c3,sum(d.ps) as ps,sum(d.weig) as weig,sum(d.charge) as charge from (select case when m.loc_code is null then s.stano else m.loc_code end as loc_code,s.station,s.c3,
isnull(m.ps,0) as ps,isnull(m.weig,0) as weig,isnull(m.charge,0) as charge from
(select loc_code,count(*) as ps,sum(weig) as weig,sum(charge) as charge from manifest where datem between @start_datem and @end_datem group by loc_code) m full outer join stat s on m.loc_code=s.stano) d group by c3) d1
GO各位帮忙看一下,有那里需要改进的地方,TKS
业务上的问题看不出来。