Sybase:存储过程GROUP

--版本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 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, 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.D_YDQHSJ2, --dd.N_YDSPSL END GO EXEC STATISTICS_FOR_SHITANG '2011/09/27'
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值