Advertisement
theitd

jCricket Bowling Stats Query

Sep 18th, 2013
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 1.26 KB | None | 0 0
  1. SELECT jcbo.player_id as pid,
  2. COUNT(jcbo.player_id) as games,
  3. SUM(jcbo.overs) as overs,
  4. SUM(jcbo.maidens) as maidens,
  5. SUM(jcbo.runs) as runs,
  6. SUM(jcbo.wickets) as wickets,
  7. FORMAT( SUM( jcbo.runs ) / (SUM( jcbo.wickets ) ),1) as average,
  8. FORMAT( SUM( jcbo.runs ) / (SUM( jcbo.overs ) ),1) as economy,
  9. jcp.first_name,
  10. jcp.last_name,
  11. MAX(jcbo.wickets) as max,
  12. (SELECT jcbo.fixture_id
  13. FROM jos_jcricket_bowling jcbo
  14.  JOIN jos_jcricket_fixtures jcf ON jcf.id = jcbo.fixture_id
  15. WHERE jcbo.player_id = pid
  16.   AND jcp.enabled = '1'
  17.   " . $filter_year . " // AND YEAR(jcf.fixture_date) BETWEEN Year('2013-03-01') AND Year('2013-09-30')
  18.   " . $filter_type . " // AND jcf.fix_type = '1'
  19.  ORDER BY jcbo.wickets DESC LIMIT 1) as fixture
  20. FROM  jos_jcricket_bowling jcbo
  21. JOIN jos_jcricket_players jcp ON jcp.id = jcbo.player_id
  22. JOIN jos_jcricket_fixtures jcf ON jcf.id = jcbo.fixture_id
  23. JOIN jos_jcricket_teams jcth ON jcth.id = jcf.h_team_id
  24. JOIN jos_jcricket_teams jct ON jct.id = jcf.a_team_id
  25. WHERE jcbo.team_id = " . $team . " // WHERE jcbo.team_id = '1'
  26. AND jcp.enabled = '1'
  27. " . $filter_type . " // AND YEAR(jcf.fixture_date) BETWEEN Year('2013-03-01') AND Year('2013-09-30')
  28. " . $filter_year . "  // AND jcf.fix_type = '1'
  29. GROUP BY jcbo.player_id
  30. ORDER BY wickets DESC;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement