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
  • 相关阅读:
    Android studio的基本使用
    Java web项目基本介绍
    关于缓存的问题
    tomcat的基本使用
    https的页面内嵌入http页面报错的问题
    RTTHREAD使用sscanf遇到的问题
    Supervisor安装与配置(Linux/Unix进程管理工具)
    MYSQL 检查表的元数据是否有异常
    多表select count语句生成 带格式化
    MYSQL压缩表测试
  • 原文地址:https://www.cnblogs.com/mxw09/p/2014319.html
Copyright © 2011-2022 走看看