theitd icon

jCricket Bowling Stats Query

theitd | PRO | 09/18/13 06:50:44 AM UTC | 0 ⭐ | 525 👁️ | Never ⏰ | []
MySQL |

1.26 KB

|

None

|

0 👍

/

0 👎

SELECT jcbo.player_id as pid,
COUNT(jcbo.player_id) as games,
SUM(jcbo.overs) as overs,
SUM(jcbo.maidens) as maidens, 
SUM(jcbo.runs) as runs,
SUM(jcbo.wickets) as wickets,
FORMAT( SUM( jcbo.runs ) / (SUM( jcbo.wickets ) ),1) as average,
FORMAT( SUM( jcbo.runs ) / (SUM( jcbo.overs ) ),1) as economy,
jcp.first_name,
jcp.last_name,
MAX(jcbo.wickets) as max,
(SELECT jcbo.fixture_id
FROM jos_jcricket_bowling jcbo
 JOIN jos_jcricket_fixtures jcf ON jcf.id = jcbo.fixture_id
WHERE jcbo.player_id = pid
  AND jcp.enabled = '1'
  " . $filter_year . " // AND YEAR(jcf.fixture_date) BETWEEN Year('2013-03-01') AND Year('2013-09-30')
  " . $filter_type . " // AND jcf.fix_type = '1'
 ORDER BY jcbo.wickets DESC LIMIT 1) as fixture 
FROM  jos_jcricket_bowling jcbo
JOIN jos_jcricket_players jcp ON jcp.id = jcbo.player_id
JOIN jos_jcricket_fixtures jcf ON jcf.id = jcbo.fixture_id
JOIN jos_jcricket_teams jcth ON jcth.id = jcf.h_team_id
JOIN jos_jcricket_teams jct ON jct.id = jcf.a_team_id
WHERE jcbo.team_id = " . $team . " // WHERE jcbo.team_id = '1'
AND jcp.enabled = '1'
" . $filter_type . " // AND YEAR(jcf.fixture_date) BETWEEN Year('2013-03-01') AND Year('2013-09-30')
" . $filter_year . "  // AND jcf.fix_type = '1'
GROUP BY jcbo.player_id
ORDER BY wickets DESC;

Comments