zoukankan      html  css  js  c++  java
  • 统计每日盈利最多的信息

    --用户投注表历史表
    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
  • 相关阅读:
    OpenResty 作者章亦春访谈实录
    linux 下C语言学习路线
    swift 集合类型
    不懂技术的人不要对懂技术的人说这很容易实现
    java学习笔记7--抽象类与抽象方法
    java学习笔记6--类的继承、Object类
    python练习题
    python的里字典和列表
    python里list列表,tuple元组内部功能介绍
    python里float和long内部功能及字符串str介绍
  • 原文地址:https://www.cnblogs.com/mxw09/p/2014319.html
Copyright © 2011-2022 走看看