|||
1、表存在则删除
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'gxf_2_batch_calender') AND type in (N'U'))
DROP TABLE gxf_2_batch_calender
2、查询累计存栏数
数据表gxf_2_batch_calender 中有各批次当日变动总数,要计算批次累计日存栏
SELECT A.batchNo,A.EVENTDATE, SUM(B.DAYCOUNT) AS ENDDAYCOUNT
into gxf_3_batch_calender
FROM gxf_2_batch_calender A INNER JOIN gxf_2_batch_calender B
ON A.batchNo=B.batchNo AND A.EVENTDATE>=B.EVENTDATE GROUP BY A.batchNo,A.EVENTDATE
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-14 12:28
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社