提交 603cfe63 编写于 作者: M monomania

1.增加统计排列sql

上级 8caa5395
SELECT
ar.`AlFlag` AS '模型',
DATE_FORMAT(ar.`MatchDate`, '%w') AS '星期',
ar.`LetBall` AS '让球',
COUNT(1) AS '总场次',
SUM(IF (ar.`Result` = "命中", 1, 0)) AS '命中',
SUM(IF (ar.`Result` = "错误", 1, 0)) AS '错误',
SUM(IF (ar.`Result` = "走盘", 1, 0)) AS '走盘',
SUM(
IF (
mh.`MainTeamGoals` > mh.`GuestTeamGoals`,
1,
0
)
) AS '主胜',
SUM(
IF (
mh.`MainTeamGoals` = mh.`GuestTeamGoals`,
1,
0
)
) AS '平局',
SUM(
IF (
mh.`MainTeamGoals` < mh.`GuestTeamGoals`,
1,
0
)
) AS '客胜'
FROM
foot.`t_analy_result` ar,
foot.`t_match_his` mh,
foot.`t_league` l
WHERE ar.`MatchId` = mh.`Id`
AND mh.`LeagueId` = l.`Id`
#and ar.`TOVoidDesc` = ''
AND ar.`Result` != "待定"
AND ar.`AlFlag` IN ('A1', 'A3')
GROUP BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`
ORDER BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`
\ No newline at end of file
SELECT
*
FROM
(SELECT
ar.`AlFlag` AS 'flag',
DATE_FORMAT(ar.`MatchDate`, '%w') AS 'week',
ar.`LetBall` AS 'letball',
COUNT(1) AS 'total',
SUM(IF (ar.`Result` = "命中", 1, 0)) AS 'right',
SUM(IF (ar.`Result` = "错误", 1, 0)) AS 'error',
SUM(IF (ar.`Result` = "走盘", 1, 0)) AS 'none',
SUM(
IF (
mh.`MainTeamGoals` > mh.`GuestTeamGoals`,
1,
0
)
) AS '3',
SUM(
IF (
mh.`MainTeamGoals` = mh.`GuestTeamGoals`,
1,
0
)
) AS '1',
SUM(
IF (
mh.`MainTeamGoals` < mh.`GuestTeamGoals`,
1,
0
)
) AS '0'
FROM
foot.`t_analy_result` ar,
foot.`t_match_his` mh,
foot.`t_league` l
WHERE ar.`MatchId` = mh.`Id`
AND mh.`LeagueId` = l.`Id` #and ar.`TOVoidDesc` = ''
AND ar.`Result` != "待定"
AND ar.`AlFlag` IN ('A1', 'A3')
#AND DATE_FORMAT(ar.`MatchDate`, '%w') = 0
GROUP BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`
ORDER BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`) t
WHERE t.total > 10
AND (
t.error / t.total >= 0.8
OR t.right / t.total >= 0.8
OR t.none / t.total >= 0.8
OR t.1/t.total > 0.5
) ORDER BY t.week ASC
\ No newline at end of file
SELECT
*
FROM
(SELECT
ar.`AlFlag` AS 'flag',
DATE_FORMAT(ar.`MatchDate`, '%w') AS 'week',
ar.`LetBall` AS 'letball',
COUNT(1) AS 'total',
SUM(IF (ar.`Result` = "命中", 1, 0)) AS 'right',
SUM(IF (ar.`Result` = "错误", 1, 0)) AS 'error',
SUM(IF (ar.`Result` = "走盘", 1, 0)) AS 'none',
SUM(
IF (
mh.`MainTeamGoals` > mh.`GuestTeamGoals`,
1,
0
)
) AS '3',
SUM(
IF (
mh.`MainTeamGoals` = mh.`GuestTeamGoals`,
1,
0
)
) AS '1',
SUM(
IF (
mh.`MainTeamGoals` < mh.`GuestTeamGoals`,
1,
0
)
) AS '0'
FROM
foot.`t_analy_result` ar,
foot.`t_match_his` mh,
foot.`t_league` l
WHERE ar.`MatchId` = mh.`Id`
AND mh.`LeagueId` = l.`Id`
AND ar.`TOVoidDesc` = ''
AND ar.`Result` != "待定"
AND ar.`AlFlag` IN ('C1', 'C2')
#AND DATE_FORMAT(ar.`MatchDate`, '%w') = 0
GROUP BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`
ORDER BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`) t
WHERE t.total > 10
AND (
t.error / t.total >= 0.8
OR t.right / t.total >= 0.8
OR t.none / t.total >= 0.8
OR t.1/t.total > 0.5
) ORDER BY t.week ASC
\ No newline at end of file
SELECT
*
FROM
(SELECT
ar.`AlFlag` AS 'flag',
DATE_FORMAT(ar.`MatchDate`, '%w') AS 'week',
ar.`LetBall` AS 'letball',
COUNT(1) AS 'total',
SUM(IF (ar.`Result` = "命中", 1, 0)) AS 'right',
SUM(IF (ar.`Result` = "错误", 1, 0)) AS 'error',
SUM(IF (ar.`Result` = "走盘", 1, 0)) AS 'none',
SUM(
IF (
mh.`MainTeamGoals` > mh.`GuestTeamGoals`,
1,
0
)
) AS '3',
SUM(
IF (
mh.`MainTeamGoals` = mh.`GuestTeamGoals`,
1,
0
)
) AS '1',
SUM(
IF (
mh.`MainTeamGoals` < mh.`GuestTeamGoals`,
1,
0
)
) AS '0'
FROM
foot.`t_analy_result` ar,
foot.`t_match_his` mh,
foot.`t_league` l
WHERE ar.`MatchId` = mh.`Id`
AND mh.`LeagueId` = l.`Id`
AND ar.`TOVoidDesc` = ''
AND ar.`Result` != "待定"
AND ar.`AlFlag` IN ('E1', 'E2')
#AND DATE_FORMAT(ar.`MatchDate`, '%w') = 0
GROUP BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`
ORDER BY ar.`AlFlag`,
DATE_FORMAT(ar.`MatchDate`, '%w'),
ar.`LetBall`) t
WHERE t.total > 10
AND (
t.error / t.total >= 0.8
OR t.right / t.total >= 0.8
OR t.none / t.total >= 0.8
OR t.1/t.total > 0.5
) ORDER BY t.week ASC
\ No newline at end of file
SELECT table_schema, table_name,table_rows
FROM information_schema.tables
WHERE table_schema='foot';
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册