--版本1
IF OBJECT_ID ('dbo.STATISTICS_FOR_SHITANG') IS NOT NULL
DROP PROCEDURE dbo.STATISTICS_FOR_SHITANG
GO
CREATE PROCEDURE STATISTICS_FOR_SHITANG
@BEGIN_TIME DATE
AS
BEGIN
SELECT
dd.C_PID,
(datepart(weekday,dd.D_YDQHSJ2)-1) AS N_WEEKDAY,
dd.D_YDQHSJ2 AS D_QHSJ,
SUM(dd.N_YDSPSL) AS N_COUNT
FROM
T_DD_SHITANG dd,
T_SP_SHITANG sp
WHERE dd.C_PID = sp.C_ID AND dd.T_YDZT = 1
AND
(
dd.D_YDQHSJ2=@BEGIN_TIME
OR dd.D_YDQHSJ2=dateadd(dd,1,@BEGIN_TIME)
OR dd.D_YDQHSJ2=dateadd(dd,2,@BEGIN_TIME)
OR dd.D_YDQHSJ2=dateadd(dd,3,@BEGIN_TIME)
OR dd.D_YDQHSJ2=dateadd(dd,4,@BEGIN_TIME)
OR dd.D_YDQHSJ2=dateadd(dd,5,@BEGIN_TIME)
OR dd.D_YDQHSJ2=dateadd(dd,6,@BEGIN_TIME)
)
GROUP BY dd.C_PID,dd.D_YDQHSJ2,dd.N_YDSPSL
--dd.D_YDQHSJ2,
--dd.N_YDSPSL
END
GO
EXEC STATISTICS_FOR_SHITANG '2011/09/27'
--版本2
IF
Sybase:存储过程GROUP
最新推荐文章于 2016-10-28 17:18:39 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)