今天开发遇到了一个问题
请教各位大神
表结构如下
问题:在表 active 中有字段chanel 根据tm的时间字段统计 各个channel不等于-1的timeAll和loginCountDayOk统计到 channel=-1的 timeAll和loginCountDayOk中
使用临时表 自己解决了
SELECT * INTO #a FROM (SELECT SUM(timeAll) AS timeAll,sum(loginCountDayOK) AS loginCountDayOK,tm FROM dbo.active f WHERE f.channel<>-1 GROUP BY tm) f
SELECT * FROM #a
UPDATE dbo.active SET timeAll=(SELECT adf FROM #a WHERE #a.tm=dbo.active.tm),loginCountDayOK=(SELECT ok FROM #a WHERE #a.tm=dbo.active.tm)
WHERE channel=-1