• 统计每日盈利最多的信息


    --用户投注表历史表
    create table t_Userinfo_his (
       rid            int              identity,
       userid               int                  not null, --用户ID
       nick                 varchar(50)          not null, --用户昵称
       termid               int                  not null, --比赛ID
       nums                 int                  not null, --投注数字
       instone              bigint               not null, --投入金额
       outstone             bigint               not null, --返还金额
       addtime              datetime             not null, --投注时间   
    )
    go



    --功能:统计每日盈利最多的用户
    --作者:测试人员
    --创建日期:2011-04-12
    create procedure p_daystar
    @date    datetime --从哪天开始统计
    as
    set nocount on
    set transaction isolation level read uncommitted
    set xact_abort on            
        --创建一个表变量,存储用户ID,用户当天总盈利,日期
        declare @tb table(userid int,outstone bigint,addtime char(10))
        insert @tb select userid,sum(outstone) as outstone,convert(char(10),addtime,20) as addtime from t_userinfo_his with(nolock)     
            where convert(char(10),addtime,20) >= @date
            group by userid ,convert(char(10),addtime,20)    
        --select * from @tb
        select addtime,max(outstone) as outstone ,userid=(select userid from @tb where addtime=a.addtime and outstone=max(a.outstone)) from @tb as a        
        group by addtime
    go
  • 相关阅读:
    Build MySQL 5.7.4 in RedHat
    glibc-2.19 之 strlen 实现
    [部署问题列表]
    [数据链路排查]
    VS配置本地IIS以域名访问
    SQL系列函数——数学函数
    面向对象编程的几个原则
    SQL系列函数——字符串函数
    SQL数据类型
    DHtmlx组件获取选中行的某一列对应的值
  • 原文地址:https://www.cnblogs.com/mxw09/p/2014319.html
Copyright © 2020-2023  润新知