Создание веб-приложения, сочетающего в себе проектирование и создание баз данных, работу со сторонними форматами данных, программирование в NET и веб-разработку, страница 75

                dt.Clear();

                da = new MySqlDataAdapter(sql, conn);

                da.Fill(dt);

                report.DataSource = dt;

                report.DataBind();

                for (int i = 0; i < report.Rows.Count; i++)

                {

                    report.Rows[i].Cells[0].Text = (i + 1).ToString();

                    if (report.Rows[i].Cells[1].Text == team) position = i + 1;

                }

                if (team != null && team != "")

                {

                    sql = "select teams.id as POS, teams.name as TEAM,sum(" + table_team_stats + ".gp) as G,sum(" + table_team_stats + ".w) as W,sum(" + table_team_stats + ".w_ot) as WOT,sum(" + table_team_stats + ".w_so) as WSO,sum(" + table_team_stats + ".l_so) as LSO,sum(" + table_team_stats + ".l_ot) as LOT,sum(" + table_team_stats + ".l) as L,sum(" + table_team_stats + ".gf) as GF, sum(" + table_team_stats + ".ga) as GA,(sum(" + table_team_stats + ".gf)-sum(" + table_team_stats + ".ga)) as GD,((sum(" + table_team_stats + ".w)*(select tournaments.w from tournaments where id = (select conferences.league from conferences inner join divisions on divisions.conference = conferences.id inner join teams on divisions.id=teams.division  inner join " + table_team_stats + " on teams.id = " + table_team_stats + ".team group by conferences.league)))+(sum(" + table_team_stats + ".w_ot)*(select tournaments.w_ot from tournaments where id = (select conferences.league from conferences inner join divisions on divisions.conference = conferences.id inner join teams on divisions.id=teams.division  inner join " + table_team_stats + " on teams.id = " + table_team_stats + ".team group by conferences.league)))+(sum(" + table_team_stats + ".w_so)*(select tournaments.w_so from tournaments where id = (select conferences.league from conferences inner join divisions on divisions.conference = conferences.id inner join teams on divisions.id=teams.division  inner join " + table_team_stats + " on teams.id = " + table_team_stats + ".team group by conferences.league)))+(sum(" + table_team_stats + ".l_so)*(select tournaments.l_so from tournaments where id = (select conferences.league from conferences inner join divisions on divisions.conference = conferences.id inner join teams on divisions.id=teams.division  inner join " + table_team_stats + " on teams.id = " + table_team_stats + ".team group by conferences.league)))+(sum(" + table_team_stats + ".l_ot)*(select tournaments.l_ot from tournaments where id = (select conferences.league from conferences inner join divisions on divisions.conference = conferences.id inner join teams on divisions.id=teams.division  inner join " + table_team_stats + " on teams.id = " + table_team_stats + ".team group by conferences.league)))+(sum(" + table_team_stats + ".l)*(select tournaments.l from tournaments where id = (select conferences.league from conferences inner join divisions on divisions.conference = conferences.id inner join teams on divisions.id=teams.division inner join " + table_team_stats + " on teams.id = " + table_team_stats + ".team group by conferences.league)))) as P FROM " + table_team_stats + " inner join teams on teams.id = " + table_team_stats + ".team and teams.name = '" + team + "';";

                    dt.Clear();

                    da = new MySqlDataAdapter(sql, conn);

                    da.Fill(dt);

                    report.DataSource = dt;

                    report.DataBind();

                    report.Rows[0].Cells[0].Text = position.ToString();

                }

                conn.Close();

            }