ALTER PROCEDURE [dbo].[STOR_totalforadmin]
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- Interfering with SELECT statements.
SET NOCOUNT ON;
-- SELECT * FROM tblDraw
SELECT tblretailer.ID,Name as retailername, tblretailer.AbcRate, tblretailer.AbRate,
tblretailer.BoxRate, tblretailer.StraightRate,
sum(isnull(ACount, 0)) as atotal ,
sum(isnull(BCount, 0)) as Btotal,
sum(isnull(CCount, 0)) as Ctotal,
SUM(isnull(Count,0)) as strtotal,
SUM(isnull(BoxCount,0)) as boxtotal,
SUM(isnull(ABCount,0))as abtotal,
SUM(isnull(ACCount,0))as actotal,
SUM(isnull(BCCount,0)) as bctotal
FROM tblretailer FULL JOIN Tbl_ABC abc ON (abc.RetailerID=tblretailer.ID)
FULL JOIN TblDraw Draw ON (Draw.RetailerID=tblretailer.ID)
FULL JOIN Tbl_ABACBC abbc ON (abbc.RetailerID=tblretailer.ID)
GROUP BY Name, tblretailer.ID, tblretailer.AbcRate, tblretailer.AbRate, tblretailer.BoxRate, tblretailer.StraightRate
END