IF EXISTS(SELECT * FROM SYS.PROCEDURES WHERE NAME='PROC_COUNT_UPDATE_PLAN_LIST')
	DROP  PROCEDURE  dbo.PROC_COUNT_UPDATE_PLAN_LIST;
GO
	
CREATE PROCEDURE PROC_COUNT_UPDATE_PLAN_LIST
AS
BEGIN
    SELECT COUNT(1) as totalCount,5000 as pageSize
    FROM (
        SELECT A.FID
        FROM T_PLN_PLANORDER A               
            INNER JOIN T_PLN_RESERVELINKENTRY B ON B.FSUPPLYBILLNO = A.FBILLNO
            INNER JOIN T_PLN_RESERVELINK C ON C.FID=B.FID
            INNER JOIN T_PLN_FORECASTENTRY D ON D.FENTRYID=C.FSRCENTRYID
            INNER JOIN T_PLN_FORECAST e on e .fid=d.FID
        WHERE  1=1
	        AND A.F_FORECASTNUMBER = ''
        GROUP BY A.FID
    ) t
END