##甲克魚 1000363 積分 10元話費*1 DELETE FROM user_gift WHERE user_gift.id=3079 AND user_gift.u_id=1000363; DELETE FROM user_exchange_info WHERE user_exchange_info.id=63 AND user_exchange_info.u_id=1000363; UPDATE user_fund SET VipPoints=VipPoints+110000 WHERE FbId=1000363; UPDATE rooms set `Status`=1 where RoomName like '%8%'; #開啓機器人相關房間 ##查詢碎片個數 select * from user_prize_log where uid = (select fbid from users where FbName = '小豆2323337173') and prizeId in (22,23); ##查詢積分狀況 select sum(vippoints)/10000 from user_fund where fbid<10000000; ##查詢每日簽到存在多條記錄 select * from signin as s right join ( select u_id,sign_date from signin where sign_date>='2015-06-01' group by u_id, sign_date having count(*) > 1 ) as aa on aa.u_id = s.u_id and aa.sign_date = s.sign_date; ##刪除一段時間數據 DELETE from game_action WHERE ActionTime<"2015-08-01 00:00:00"; ##比賽場名次查詢 SELECT fbid,fbname from users where fbid in (SELECT fbid from match_users where matchid=1508 ORDER BY FbId DESC); SELECT * from match_users where matchid=1508; SELECT * from matchs where MatchStopTime="2015-09-19 14:00:00" and MatchConfigId=3; ##商品合成ID UPDATE goods_compound_log gcl, goods_compound gc SET gcl.g_id = gc.g_id WHERE gcl.f_id = gc.f_id; ##批量更新籌碼 UPDATE user_fund set chips=chips+90000 WHERE u_id in (1019133 ,1056848 ,1053731 ,1036275 ,1015810 ,1055824 ,1054226 ,1003362); ##增長vip等級1爲3天時間 update user_vip set valid_time = if(valid_time < now(), '2015-10-25 19:00:00', date_add(valid_time, interval 3 day)) ,lv=1 where u_id in(1000001,1000002,1000003,1000004); ##添加公關爲1天時間 insert into user_gift(g_id, u_id, number, g_type, is_adorn, cre_time, valid_time) values(24557, 1055824, 1, 2, 0, now(), date_add(now(), interval 1 day)); ##添加大喇叭爲23天 insert into user_gift(g_id, u_id, number, g_type, is_adorn, cre_time, valid_time) values(31121, 1046373, 2500, 3, 0, now(), date_add(now(), interval 23 day)); ##查詢昨日贏利牌行榜 SELECT uid, g.chips AS chips, uv.lv AS vipLevel, ui.nickname, ui.is_robot AS type, ui.figureurl AS p_w_picpath FROM ( SELECT fbid AS uid, SUM(ChangeChips) AS chips FROM game_userlog force index(ix_gametime) WHERE begintime >= '2015-11-02 04:00:00.0' AND begintime < '2015-11-03 04:00:00.0' GROUP BY fbid ORDER BY chips DESC LIMIT 0, 30 ) g, user_count uc, user_info ui, user_vip uv WHERE g.uid = uc.u_id AND g.uid = ui.u_id AND g.uid = uv.u_id AND g.chips > 0; ##到達大廳人數 set @startdate='2015-6-18 4:00:00'; set @enddate='2015-6-19 4:00:00'; select (select count(alu.fbid) from (select fbid,count(fbid) from user_node_log where node=0 and CreateTime>=@startdate and CreateTime<=@enddate group by fbid) as alu) as 全部用戶訪問人數, (select sum(ucount) from (select fbid,count(fbid) as ucount from user_node_log where node=0 and CreateTime>=@startdate and CreateTime<=@enddate group by fbid) as fwrs) as 全部用戶訪問次數, (select count(alu.fbid) from (select fbid,count(fbid) from user_node_log where node=9 and CreateTime>=@startdate and CreateTime<=@enddate group by fbid) as alu) as 全部用戶到大廳人數, (select sum(alu.count) from (select fbid,count(fbid) as count from user_node_log where node=9 and CreateTime>=@startdate and CreateTime<=@enddate group by fbid) as alu) as 全部用戶到大廳次數, (select count(*) from (select unl.fbid,count(unl.fbid) from user_node_log as unl,(select fbid from users where RegTime>=@startdate and RegTime<=@enddate) as un where unl.fbid=un.fbid and unl.node=9 and unl.CreateTime>=@startdate and unl.CreateTime<=@enddate group by unl.fbid) as nunl) as 新用戶到大廳人數, (select count(*) from (select gu.fbid from game_userlog as gu, (select fbid,count(fbid) from user_node_log where node=9 and CreateTime>=@startdate and CreateTime<=@enddate group by fbid) as lu where gu.fbid=lu.fbid and gu.EndTime>=@startdate and gu.EndTime<=@enddate group by gu.fbid) as lwp) as 全部用戶到大廳玩牌人數, (select count(*) from (select gu.fbid from game_userlog as gu, (select unl.fbid,count(unl.fbid) from user_node_log as unl,(select fbid from users where RegTime>=@startdate and RegTime<=@enddate) as un where unl.fbid=un.fbid and unl.node=9 and unl.CreateTime>=@startdate and unl.CreateTime<=@enddate group by unl.fbid) as lu where gu.fbid=lu.fbid and gu.EndTime>=@startdate and gu.EndTime<=@enddate group by gu.fbid) as lwp) as 新用戶到大廳玩牌人數 insert into goods_price(`type`,`g_id`,`currency_type`,`price`) select 1 AS type, id AS g_id, currency_type, price from goods where currency_type in(1,3,4) order by g_id;
#取出保險箱籌碼 update user_fund uf, safe s set uf.chips = uf.chips + s.amount, s.amount = 0 where uf.u_id = s.u_id and uf.u_id not in ( select distinct u_id from ( #####去除重複的記錄 select u_id from deposit union all select u_id from tcpay_log ) aa ) and uf.u_id not in(1008728, 1064569, 1064491, 1056812); #查詢保險箱籌碼 select ui.u_id, ui.nickname, s.amount from safe s, user_info ui where ui.u_id = s.u_id and amount > 0;
# 修改用戶帳戶籌碼 update user_fund uf, user_info ui set chips = case when ui.last_login_time < '2015-06-16' and chips > 3000 then 3000 when ui.last_login_time < '2015-11-16' and chips > 10000 then 10000 when ui.last_login_time > '2015-11-16' and chips > 50000 then 50000 else chips end where uf.u_id = ui.u_id and uf.u_id not in ( select distinct u_id from ( select u_id from deposit union all select u_id from tcpay_log ) aa ) and ui.is_robot = 0 and uf.u_id not in(1008728, 1064569, 1064491, 1056812); # 查詢玩家籌碼: select ui.u_id, ui.nickname, uf.chips from user_fund uf, user_info ui where uf.u_id = ui.u_id and uf.u_id<20000000000000 ORDER BY uf.chips desc;
CREATE TABLE `plotline` ( `id` int(11) NOT NULL COMMENT '主線任務id', `title` varchar(50) NOT NULL COMMENT '任務標題', `content` varchar(150) NOT NULL COMMENT '內容', `n_id` int(11) NOT NULL COMMENT '下一個任務id', `type` int(11) NOT NULL COMMENT '任務類型', `state` tinyint(2) NOT NULL COMMENT '狀態 0取消 1使用', `criterion` int(11) NOT NULL COMMENT '條件', `prize_type` tinyint(4) NOT NULL COMMENT '獎品類型 0沒有 1貨幣 2商品 3禮包 4抽獎次數', `prize_id` int(11) NOT NULL COMMENT '獎品id', `prize_num` int(11) NOT NULL COMMENT '獎品數量', PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; insert into `plotline` (`id`, `title`, `content`, `n_id`, `type`, `state`, `criterion`, `prize_type`, `prize_id`, `prize_num`) values('1','「盲注5/10」玩牌一次','參加一次牌局(加入QQ羣:237101389暗號:福利,找客服就能換話費哦)。','2','1014','1','1','3','53','1'); insert into `plotline` (`id`, `title`, `content`, `n_id`, `type`, `state`, `criterion`, `prize_type`, `prize_id`, `prize_num`) values('2','跟注一次','當您以爲牌型不錯的時候,不妨點擊一次「跟注」看看。','3','1111','1','1','1','3','400'); insert into `plotline` (`id`, `title`, `content`, `n_id`, `type`, `state`, `criterion`, `prize_type`, `prize_id`, `prize_num`) values('3','棄牌一次','當您以爲牌型落後的時候,能夠點擊「棄牌」放棄哦。','4','1112','1','1','1','3','400');
CREATE TABLE `entry_group` ( `entry` varchar(255) NOT NULL, `gid` tinyint(4) NOT NULL, `name` varchar(255) DEFAULT NULL, `info` varchar(255) DEFAULT NULL, KEY `index_entry` (`entry`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; INSERT INTO `entry_group` VALUES ('web_qq', '1', 'qq空間', 'qq空間'); INSERT INTO `entry_group` VALUES ('web_joker', '2', '官網', '官網'); INSERT INTO `entry_group` VALUES ('mobile_qq', '3', '應用寶', '應用寶qq'); INSERT INTO `entry_group` VALUES ('mobile_wx', '3', '應用寶', '應用寶微信'); ALTER TABLE `user_info` ADD COLUMN `egid` TINYINT DEFAULT 0 NULL AFTER `entry`; UPDATE user_info u INNER JOIN entry_group e ON u.entry = e.entry SET u.egid = e.gid ; BEGIN SET @pf = new.entry; SET @aa = (SELECT gid FROM entry_group WHERE entry = @pf); SET new.egid = @aa; END
活躍在線數據統計 select sum(sec0) as "活躍在線總人數" ,sum(sec1) as "活躍時長〉5時長〈=15" ,sum(sec2) as "活躍時長〉15時長〈=60" ,sum(sec3) as "活躍時長〉60時長〈=180" ,sum(sec4) as "活躍時長〉180時長〈=480" ,sum(sec5) as "活躍時長〉480" FROM ( select CASE WHEN sec>15*60 THEN 1 ELSE 0 END as sec0, CASE WHEN sec>5*60 and sec<=15*60 THEN 1 ELSE 0 END as sec1, CASE WHEN sec>15*60 and sec<=60*60 THEN 1 ELSE 0 END as sec2, CASE WHEN sec>60*60 and sec<=180*60 THEN 1 ELSE 0 END as sec3, CASE WHEN sec>180*60 and sec<=480*60 THEN 1 ELSE 0 END as sec4, CASE WHEN sec>480*60 THEN 1 ELSE 0 END as sec5 from ( select sum(UNIX_TIMESTAMP(t.EndTime)-UNIX_TIMESTAMP(t.BeginTime)) as sec from (select distinct gu.FbId, gu.BeginTime, gu.EndTime from game_userlog gu, users u where gu.FbId = u.FbId and u.IsRobot=0 and gu.BeginTime >= '2015-06-07 04:00:00' and gu.EndTime < '2015-06-08 04:00:00' ) t GROUP BY t.FbId )tt )ttt;
DELIMITER $$ DROP PROCEDURE IF EXISTS `qqtexas`.`p_user_chips_log`$$ CREATE DEFINER=`develop`@`%` PROCEDURE `p_user_chips_log`() BEGIN TRUNCATE TABLE p_user_chips; INSERT INTO p_user_chips(u_id, chips, cre_time) SELECT u_id, SUM(chips) as chips, now() AS cre_time FROM ( SELECT u_id, chips FROM user_fund UNION ALL SELECT u_id, amount AS chips FROM safe ) aa GROUP BY u_id; END
BEGIN DECLARE n_minid BIGINT; DECLARE n_maxid BIGINT; DECLARE n_rows BIGINT DEFAULT 1000; DECLARE n_sleep INT DEFAULT 0; DECLARE n_day INT DEFAULT 7; SET autocommit=0; SELECT id INTO n_minid FROM game_action ORDER BY id LIMIT 1; SELECT MAX(id) INTO n_maxid FROM game_action WHERE RoundID = ( SELECT RoundID FROM game_log WHERE BeginTime<DATE_SUB(NOW(),INTERVAL n_day DAY) ORDER BY BeginTime DESC LIMIT 1); WHILE n_minid <= n_maxid - n_rows DO DELETE FROM game_action WHERE id BETWEEN n_minid AND n_minid + n_rows; COMMIT; IF n_sleep > 0 THEN SELECT SLEEP(n_sleep); END IF; SET n_minid = n_minid + n_rows; END WHILE; SELECT id INTO n_minid FROM match_gameaction ORDER BY id LIMIT 1; SELECT MAX(id) INTO n_maxid FROM match_gameaction WHERE RoundID = ( SELECT RoundID FROM match_gamelog WHERE BeginTime<DATE_SUB(NOW(),INTERVAL n_day DAY) ORDER BY BeginTime DESC LIMIT 1); WHILE n_minid <= n_maxid - n_rows DO DELETE FROM match_gameaction WHERE id BETWEEN n_minid AND n_minid + n_rows; COMMIT; IF n_sleep > 0 THEN SELECT SLEEP(n_sleep); END IF; SET n_minid = n_minid + n_rows; END WHILE; SELECT RoundID INTO n_minid FROM gen_roundid ORDER BY RoundID LIMIT 1; SELECT RoundID-1000 INTO n_maxid FROM gen_roundid ORDER BY RoundID DESC LIMIT 1; WHILE n_minid <= n_maxid - n_rows DO DELETE FROM gen_roundid WHERE RoundID BETWEEN n_minid AND n_minid + n_rows; COMMIT; IF n_sleep > 0 THEN SELECT SLEEP(n_sleep); END IF; SET n_minid = n_minid + n_rows; END WHILE; SELECT RoundID INTO n_minid FROM match_roundid ORDER BY RoundID LIMIT 1; SELECT RoundID-1000 INTO n_maxid FROM match_roundid ORDER BY RoundID DESC LIMIT 1; WHILE n_minid <= n_maxid - n_rows DO DELETE FROM match_roundid WHERE RoundID BETWEEN n_minid AND n_minid + n_rows; COMMIT; IF n_sleep > 0 THEN SELECT SLEEP(n_sleep); END IF; SET n_minid = n_minid + n_rows; END WHILE; SET autocommit=1; END
BEGIN DECLARE r_id INT; DECLARE r_fbid BIGINT; DECLARE r_toid BIGINT; DECLARE r_type TINYINT; DECLARE r_time TIMESTAMP; DECLARE r_isfriend INT; DECLARE b INT DEFAULT 0; DECLARE r_ids CURSOR FOR SELECT Id FROM user_relation WHERE RelationType != 0 AND RelationFlag = 0 AND fbid < 1111111111111; DECLARE CONTINUE HANDLER FOR NOT FOUND SET b = 1; OPEN r_ids; REPEAT FETCH r_ids INTO r_id; SELECT Fbid,ObjectFbId,RelationType,CreateTime INTO r_fbid,r_toid,r_type,r_time FROM user_relation WHERE Id = r_id; #是不是好友 0不是 1是 SELECT SUM(c) INTO r_isfriend FROM ( SELECT COUNT(*) AS c FROM user_friends WHERE u_id = r_fbid AND friend_id = r_toid UNION ALL SELECT COUNT(*) AS c FROM user_friends WHERE u_id = r_toid AND friend_id = r_fbid ) aa; IF r_isfriend <= 0 THEN INSERT INTO user_friends(u_id, friend_id, type, cre_time) VALUES (r_fbid, r_toid, r_type, r_time); END IF; UNTIL b = 1 END REPEAT; CLOSE r_ids; END
BEGIN set @starttime = date_sub(date_add(date(now()),interval 4 hour),interval 1 day); set @endtime = date_add(date(now()),interval 4 hour); set @login_cnt = (select count(distinct(fbid)) from user_login_log where loginTime >= @starttime and loginTime < @endtime); set @active_cnt = (select count(distinct(fbid)) from game_userlog where BeginTime >= @starttime and BeginTime < @endtime); set @register_cnt = (select count(fbid) from users where regtime >= @starttime and regtime < @endtime); set @logonday2 = (select count(distinct(fbid)) from user_login_log a where logintime < date_add( date_add(date((select RegTime as regtime from users where fbid= a.fbid)),interval 4 hour) ,interval 1 day )); set @logonday3 = (select count(distinct(fbid)) from user_login_log a where logintime >= date_add( date_add(date((select RegTime as regtime from users where fbid= a.fbid)),interval 4 hour) ,interval 1 day ) and logintime < date_add( date_add(date((select RegTime as regtime from users where fbid= a.fbid)),interval 4 hour) ,interval 2 day )); set @logonday7 = (select count(distinct(fbid)) from user_login_log a where logintime >= date_add( date_add(date((select RegTime as regtime from users where fbid= a.fbid)),interval 4 hour) ,interval 5 day ) and logintime < date_add( date_add(date((select RegTime as regtime from users where fbid= a.fbid)),interval 4 hour) ,interval 6 day )); set @sumchips = (select sum(chips) from user_fund); set @r_sumchips = (select sum(chips) from user_fund where fbid in (select fbid from users where IsRobot=1)); set @totalcharge = (select sum(amt) from deposit where upd_time >= @starttime and upd_time < @endtime); set @num_times = (select concat(CAST(count(distinct(u_id)) as char)," / ",cast(count(u_id) as char)) from deposit where upd_time >= @starttime and upd_time < @endtime); set @sign_num = (select count(distinct(u_id)) from signin where sign_date >= @starttime and sign_date < @endtime); set @award8 = (select count(distinct(u_id)) from activity_award_log where award_id=8 and cre_time >= @starttime and cre_time < @endtime); set @activ4 = (select concat(CAST(count(distinct(u_id)) as char)," / ",cast(count(u_id) as char)) from activity_award_log where activ_id=4 and cre_time >= @starttime and cre_time < @endtime); set @award10 = (select count(distinct(u_id)) from activity_award_log where award_id=10 and cre_time >= @starttime and cre_time < @endtime); set @award11 = (select count(distinct(u_id)) from activity_award_log where award_id=11 and cre_time >= @starttime and cre_time < @endtime); set @award12 = (select count(distinct(u_id)) from activity_award_log where award_id=12 and cre_time >= @starttime and cre_time < @endtime); set @award13 = (select count(distinct(u_id)) from activity_award_log where award_id=13 and cre_time >= @starttime and cre_time < @endtime); set @award14 = (select count(distinct(u_id)) from activity_award_log where award_id=14 and cre_time >= @starttime and cre_time < @endtime); set @award15 = (select count(distinct(u_id)) from activity_award_log where award_id=15 and cre_time >= @starttime and cre_time < @endtime); set @award46 = (select count(distinct(u_id)) from activity_award_log where award_id=46 and cre_time >= @starttime and cre_time < @endtime); set @award47 = (select count(distinct(u_id)) from activity_award_log where award_id=47 and cre_time >= @starttime and cre_time < @endtime); set @award48 = (select count(distinct(u_id)) from activity_award_log where award_id=48 and cre_time >= @starttime and cre_time < @endtime); set @award49 = (select count(distinct(u_id)) from activity_award_log where award_id=49 and cre_time >= @starttime and cre_time < @endtime); set @award50 = (select count(distinct(u_id)) from activity_award_log where award_id=50 and cre_time >= @starttime and cre_time < @endtime); set @all9k = (SELECT sum(GoldValue) from user_fund); set @jbp_num_times = ""; SET @allvippoint = (SELECT SUM(VipPoints) FROM user_fund WHERE fbid<1000000000); SET @robotchippool = (SELECT ConfigValue FROM sys_config WHERE `ConfigKey` = 'robotallchips'); SET @jewelbox = (SELECT ConfigValue FROM `sys_config` WHERE `ConfigKey` = 'jewelboxmoney'); SET @phonepiece = (SELECT SUM(number) FROM user_gift WHERE (g_id = '90001' OR g_id = '90002')); insert into basic_run_data(create_time,fetch_date,logon_count,active_count,install_count, logon_twice_count,logon_third_count,logon_week_count,sys_total,robot_total, charge_sum,charge_count_times, allgold,allvippoint,robotchippool,jewelbox,phonepiece) values(NOW(),date_format(date_sub(date(now()),interval 1 day), '%Y-%m-%d'), @login_cnt,@active_cnt,@register_cnt,@logonday2,@logonday3,@logonday7, @sumchips,@r_sumchips,@totalcharge,@num_times,@all9k,@allvippoint,@robotchippool,@jewelbox,@phonepiece); insert into active_run_data(fetch_date,signin_count,first_charge_count,draw_num_times, five_award_count,ten_award_count,thirty_award_count,sixty_award_count,twoh_award_count, threeh_award_count,three_fruit_count,ten_fruit_count,twentyfive_fruit_count, fifty_fruit_count,eighty_fruit_count,jbp_num_times) values(date_format(date_sub(date(now()),interval 1 day), '%Y-%m-%d'),@sign_num, @award8,@activ4,@award10,@award11,@award12,@award13,@award14,@award15,@award46, @award47,@award48,@award49,@award50,@jbp_num_times); END
ALTER TABLE `game_userlog` ADD INDEX `ix_RoomLevel` (`RoomLevel`, `FbId`, `BeginTime`) USING BTREE ; ALTER TABLE `goods` ADD COLUMN `valid_time` timestamp NULL COMMENT '有效期 具體哪天' AFTER `valid_time`; ALTER TABLE `users` ADD COLUMN `address` varchar(200) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '地址' AFTER `phone`, ADD COLUMN `realName` varchar(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL COMMENT '真實姓名' AFTER `address`; lter table `qqtexas`.`user_vip_log` add column `type` tinyint NOT NULL COMMENT '類型 1首次贈送 2每日登錄贈送' after `uv_id`; alter table `qqtexas`.`safe_log` add column `to_uid` bigint NOT NULL COMMENT '對方id' after `u_id`,change `s_id` `u_id` bigint(11) NOT NULL comment '用戶id'; ##商城修改user_vip_log表字段 alter table `qqtexas`.`user_vip_log` add column `points` int NOT NULL COMMENT '點數' after `chips`,change `amt` `chips` int(11) NOT NULL comment '領取籌碼'; alter table `qqtexas`.`user_vip_log` change `uv_id` `uv_id` varchar(50) NOT NULL comment '用戶vip id user_gift表主鍵'; alter table `qqtexas`.`user_goods_log` drop column `u_id`,change `ugoods_id` `user_goods_id` int(11) NOT NULL comment '用戶商品id'; alter table `qqtexas`.`user_goods_log` drop column `num`, drop column `g_type`, drop column `price`; alter table `qqtexas`.`users` add column `is_get_friends` tinyint(2) DEFAULT '0' NOT NULL COMMENT '是否已經獲取過平臺好友 0否 1是' after `IsRobot`,change `IsRobot` `IsRobot` tinyint(4) default '0' NOT NULL comment '是否機器人 0否 1是'; ##修改表名 rename table `qqtexas`.`goods_compound_config` to `qqtexas`.`goods_compound`; insert into goods_use_interval(g_id, interval_time) select id as g_id, timeinterval as interval_time from goods where id in(31120, 31121); insert into gift_bag(b_id, b_name, img, g_type, g_id, num, send_type, status) values (9000, '首衝大禮包', 'joker', 1, 3, 60000, 0, 1), (9000, '首衝大禮包', 'joker', 2, 31121, 4, 0, 1), (9000, '首衝大禮包', 'joker', 2, 24559, 1, 0, 1), insert into goods_price(`type`,`g_id`,`currency_type`,`price`) select 1 AS type, id AS g_id, currency_type, price from goods where currency_type in(1,3,4) order by g_id;
##修正用戶好友數量 UPDATE user_count uc, ( SELECT uid, SUM(c) AS friend_count FROM ( SELECT u_id AS uid, COUNT(*) AS c FROM user_friends GROUP BY u_id UNION ALL SELECT friend_id AS uid, COUNT(*) AS c FROM user_friends GROUP BY friend_id ) aa GROUP BY uid ) uf, ( SELECT u_id AS uid, COUNT(*) invite_count FROM user_invite GROUP BY u_id ) ui, ( SELECT u_id AS uid, COUNT(*) share_count FROM user_invite GROUP BY u_id ) us SET uc.friend_count = uf.friend_count, uc.invite_count = ui.invite_count, uc.share_count = us.share_count WHERE uc.u_id = uf.uid AND uc.u_id = ui.uid AND uc.u_id = us.uid;
##平臺修改 UPDATE user_count uc, ( SELECT u_id AS uid, COUNT(*) achieve_count FROM user_achieve GROUP BY u_id ) ua SET uc.achieve_count = ua.achieve_count WHERE uc.u_id = ua.uid;
##聚寶盆數據統計 select count(distinct t.Fbid) as "聚寶盆投注總人數" , count(t.Fbid) as "聚寶盆投注總次數" , count(distinct Winner) as "聚寶盆中獎人數" , SUM(t.WinnerCou) as "聚寶盆中獎次數" , SUM(t.WinMoney) as "聚寶盆中獎總金額" , count(t.Fbid) * 1800 - SUM(t.WinMoney) as "聚寶盆盈虧" from ( select Fbid, WinMoney , CASE WHEN WinMoney > 0 then 1 ELSE 0 end as WinnerCou , CASE WHEN WinMoney > 0 then Fbid ELSE NULL end as Winner from jewel_box where WinTime >= '2015-04-22 04:00:00' and WinTime < '2015-04-23 04:00:00' )t;
##瑤瑤樂數據統計 select count(distinct t.Fbid) as "搖搖樂投注總人數" , count(t.Fbid) as "搖搖樂投注總次數" , count(distinct Winner) as "搖搖樂中獎人數" , SUM(t.WinnerCou) as "搖搖樂中獎次數" , SUM(t.winchips) as "搖搖樂中獎總金額" , SUM(t.betchips) - SUM(t.winchips) as "搖搖樂盈虧" from ( select Fbid, winchips,betchips , CASE WHEN winchips > 0 then 1 ELSE 0 end as WinnerCou , CASE WHEN winchips > 0 then Fbid ELSE NULL end as Winner from betShake_log where bettime >= '2015-05-07 04:00:00' and bettime < '2015-05-08 04:00:00' )t;
##用戶登陸統計 select sum(a.count0) as "登陸用戶" , sum(a.count1) as "非零用戶" , sum(a.count2) as "活躍用戶" from ( select CASE WHEN t.FbId>0 then 1 ELSE 0 END as count0, CASE WHEN tt.ExpValue>10 or tt.ExpValue < -10 then 1 ELSE 0 END as count1, CASE WHEN ttt.sec>15*60 THEN 1 ELSE 0 END as count2 from users u, ( select distinct FbId from user_login_log where LoginTime >= '2015-04-27 04:00:00' and LoginTime < '2015-04-28 04:00:00' )t LEFT JOIN ( select SUM(exp_value) as ExpValue, u_id from user_exp_log where cre_time >= '2015-04-27 04:00:00' and cre_time < '2015-04-28 04:00:00' GROUP BY u_id )tt on t.FbId = tt.u_id LEFT JOIN ( select sum(UNIX_TIMESTAMP(temp.EndTime)-UNIX_TIMESTAMP(temp.BeginTime)) as sec, temp.FbId from (select distinct gu.FbId, gu.BeginTime, gu.EndTime from game_userlog gu where gu.BeginTime >= '2015-04-27 04:00:00' and gu.EndTime < '2015-04-28 04:00:00' ) temp GROUP BY temp.FbId )ttt on t.FbId = ttt.FbId where u.FbId = t.FbId and u.IsRobot=0 ) a;