SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data1.t_relation a
WHERE
a.t_promoterID = 1122864
AND a.t_accountID <> 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data1.t_customerRelation a
WHERE
a.t_promoterID = 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data2.t_relation a
WHERE
a.t_promoterID = 1122864
AND a.t_accountID <> 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data2.t_customerRelation a
WHERE
a.t_promoterID = 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data3.t_relation a
WHERE
a.t_promoterID = 1122864
AND a.t_accountID <> 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data3.t_customerRelation a
WHERE
a.t_promoterID = 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data4.t_relation a
WHERE
a.t_promoterID = 1122864
AND a.t_accountID <> 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data4.t_customerRelation a
WHERE
a.t_promoterID = 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data5.t_relation a
WHERE
a.t_promoterID = 1122864
AND a.t_accountID <> 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data5.t_customerRelation a
WHERE
a.t_promoterID = 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data6.t_relation a
WHERE
a.t_promoterID = 1122864
AND a.t_accountID <> 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data6.t_customerRelation a
WHERE
a.t_promoterID = 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data7.t_relation a
WHERE
a.t_promoterID = 1122864
AND a.t_accountID <> 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data7.t_customerRelation a
WHERE
a.t_promoterID = 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data8.t_relation a
WHERE
a.t_promoterID = 1122864
AND a.t_accountID <> 1122864 union all
SELECT
a.t_accountID,
0 t_rebateValue,
0 t_baseValue,
0 t_balance
FROM
platform_data8.t_customerRelation a
WHERE
a.t_promoterID = 1122864
-- t_rebateValue 产生返利金额
SELECT
t_accountID,
SUM(t_rebateValue)/100 t_rebateValue
FROM (
SELECT
b.t_rebateFromAccountID t_accountID,
IFNULL(SUM(b.t_rebateValue), 0) t_rebateValue
FROM NewPlatform_Log.t_careerRebateDetailLog20181110235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.t_rebateFromAccountID = c.t_accountID
WHERE b.t_accountID = 21850
AND b.t_rebateTime>=1542902400
AND b.t_rebateTime<1542988800
GROUP BY b.t_rebateFromAccountID
union all SELECT
b.t_rebateFromAccountID t_accountID,
IFNULL(SUM(b.t_rebateValue), 0) t_rebateValue
FROM NewPlatform_Log.t_careerRebateDetailLog20181112235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.t_rebateFromAccountID = c.t_accountID
WHERE b.t_accountID = 21850
AND b.t_rebateTime>=1542902400
AND b.t_rebateTime<1542988800
GROUP BY b.t_rebateFromAccountID
union all SELECT
b.t_rebateFromAccountID t_accountID,
IFNULL(SUM(b.t_rebateValue), 0) t_rebateValue
FROM NewPlatform_Log.t_careerRebateDetailLog20181113235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.t_rebateFromAccountID = c.t_accountID
WHERE b.t_accountID = 21850
AND b.t_rebateTime>=1542902400
AND b.t_rebateTime<1542988800
GROUP BY b.t_rebateFromAccountID
union all SELECT
b.t_rebateFromAccountID t_accountID,
IFNULL(SUM(b.t_rebateValue), 0) t_rebateValue
FROM NewPlatform_Log.t_careerRebateDetailLog20181114235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.t_rebateFromAccountID = c.t_accountID
WHERE b.t_accountID = 21850
AND b.t_rebateTime>=1542902400
AND b.t_rebateTime<1542988800
GROUP BY b.t_rebateFromAccountID
union all SELECT
b.t_rebateFromAccountID t_accountID,
IFNULL(SUM(b.t_rebateValue), 0) t_rebateValue
FROM NewPlatform_Log.t_careerRebateDetailLog20181115235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.t_rebateFromAccountID = c.t_accountID
WHERE b.t_accountID = 21850
AND b.t_rebateTime>=1542902400
AND b.t_rebateTime<1542988800
GROUP BY b.t_rebateFromAccountID
union all SELECT
b.t_rebateFromAccountID t_accountID,
IFNULL(SUM(b.t_rebateValue), 0) t_rebateValue
FROM NewPlatform_Log.t_careerRebateDetailLog20181116235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.t_rebateFromAccountID = c.t_accountID
WHERE b.t_accountID = 21850
AND b.t_rebateTime>=1542902400
AND b.t_rebateTime<1542988800
GROUP BY b.t_rebateFromAccountID
) t
GROUP BY t_accountID
-- t_baseValue 成员下注额
SELECT
t_accountID,
SUM(t_baseValue)/100 t_baseValue
FROM (SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181001235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181002235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181003235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181004235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181005235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181006235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181007235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181008235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181009235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181010235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181011235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181012235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181013235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181014235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181015235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181016235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181017235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181018235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181019235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181020235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181021235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181022235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181023235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181024235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181025235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181026235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181027235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181028235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181029235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181030235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181031235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181101235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181102235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181103235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181104235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181105235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181106235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181107235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181108235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181109235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181110235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181111235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181112235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181113235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181114235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181115235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
union all SELECT
b.UserID t_accountID,
IFNULL(SUM(b.Stake), 0) t_baseValue
FROM NewPlatform_Log.RecordUserScorePerGame20181116235959 b
inner join NewPlatformData.NextLevel1501375171 c ON b.UserID = c.t_accountID
WHERE b.EndTime>=1542902400
AND b.EndTime<1542988800
GROUP BY b.UserID
) t
GROUP BY t_accountID