select top 10 UserAccounts.userid,isnull(Nickname,'') as Nickname ,isnull(sum(GiftCount*50),0) as score, GiftID from UserAccounts
join GiveGiftLog
on UserID2 = UserAccounts.userid
and giftid = 101
and usertype=20
and RecordTime between DATEADD(ww, DATEDIFF(ww,0,getdate()),0) and DateAdd(ww, 1, DATEADD(ww, DATEDIFF(ww,0,getdate()),0))
group by UserAccounts.userid,Nickname,giftid
having sum(GiftCount*50) > 2400000
order by score desc
join GiveGiftLog
on UserID2 = UserAccounts.userid
and giftid = 101
and usertype=20
and RecordTime between DATEADD(ww, DATEDIFF(ww,0,getdate()),0) and DateAdd(ww, 1, DATEADD(ww, DATEDIFF(ww,0,getdate()),0))
group by UserAccounts.userid,Nickname,giftid
having sum(GiftCount*50) > 2400000
order by score desc
解决方案 »
- 在线等,,请教大家一个事务的问题,,,急急急
- 一个简单的查询问题
- 求教务管理的需求分析规范说明书
- 在建表的时候,要做行数的限制应该怎么做?
- 请教个问题,sql2000倒入的时候varchar默认是8000,sql2005倒入varchar默认是50左右,怎么修改这个默认值呢?谢谢
- 【从新问昨天晚上那个简单得不得了的问题!】
- 问大家一个很复杂的问题,搞了半天,郁闷啊~
- mssql 架构对比 权限 应该如何授予?
- 求一个sql语句。
- 我用odbc数据源和查询分析器都能连接远程服务器,可是用企业管理器"新建注册"在连接时提示:"超时已过期",这怎么办?
- ql远程调用存储过程变量问题
- mssql 联合查询提问题?我看了论坛的帐子好像都没有我这种情况
join GiveGiftLog
on UserID2 = UserAccounts.userid
and giftid = 101
and usertype=20
and RecordTime between DATEADD(ww, DATEDIFF(ww,0,getdate()),0) and DateAdd(ww, 1, DATEADD(ww, DATEDIFF(ww,0,getdate()),0))
group by UserAccounts.userid,Nickname,giftid
having isnull(sum(GiftCount*50),0)>2400000
order by score desc