日期:2014-05-17 浏览次数:20377 次
select CONVERT(varchar(10),uc.pay_time,3) pay_time
,COUNT(*) xiaofeishuliang
,SUM(CONVERT(decimal(18,2),uc.amount)) xiaofeizongji
,SUM(CONVERT(decimal(18,2),uc.amount)) shijizongji
,SUM(CONVERT(decimal(18,2),uc.amount))/COUNT(*) renjun
from ucpayorder as uc
where uc.gameId=504002
group by uc.pay_time
CREATE TABLE #TESTT(gameId INT IDENTITY(1,1) PRIMARY KEY,pay_time DATETIME,amount INT)
SELECT * FROM #TESTT
INSERT INTO #TESTT VALUES (GETDATE(),100)
SELECT CONVERT(VARCHAR(10),t.pay_time,3) AS 'pay_time',
COUNT(1) AS 'xiaofeishuliang' ,
SUM(CONVERT(DECIMAL(18,2),T.amount))AS 'xiaofeizongji',
SUM(CONVERT(DECIMAL(18,2),T.amount))AS 'shijizongji',
avg(CONVERT(DECIMAL(18,2),T.amount))AS 'renjun'
FROM #TESTT t
GROUP BY t.pay_time
GO