Leetcode力扣 MySQL数据库 1841 联赛信息统计

    2025-10-06 22:41:26

    Leetcode力扣 MySQL数据库 1841 联赛信息统计

    最新推荐文章于 2025-10-05 14:59:44 发布

    原创

    最新推荐文章于 2025-10-05 14:59:44 发布

    ·

    361 阅读

    ·

    0

    ·

    1

    ·

    CC 4.0 BY-SA版权

    版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

    文章标签:

    #数据库

    #leetcode

    #mysql

    通过SQL查询,统计League中各队伍的比赛信息,包括比赛次数、积分、进球数、失球数及净胜球。结果按积分降序、净胜球降序及队伍名称字典序排列。示例展示了Ajax、Dortmund和Arsenal三队的比赛数据和统计结果。

    1841 联赛信息统计

    SQL架构

    Create table If Not Exists Teams_1841 (team_id int, team_name varchar(20));

    Create table If Not Exists Matches_1841 (home_team_id int, away_team_id int, home_team_goals int, away_team_goals int);

    Truncate table Teams_1841;

    insert into Teams_1841 (team_id, team_name) values ('1', 'Ajax');

    insert into Teams_1841 (team_id, team_name) values ('4', 'Dortmund');

    insert into Teams_1841 (team_id, team_name) values ('6', 'Arsenal');

    Truncate table Matches_1841;

    insert into Matches_1841 (home_team_id, away_team_id, home_team_goals, away_team_goals) values ('1', '4', '0', '1');

    insert into Matches_1841 (home_team_id, away_team_id, home_team_goals, away_team_goals) values ('1', '6', '3', '3');

    insert into Matches_1841 (home_team_id, away_team_id, home_team_goals, away_team_goals) values ('4', '1', '5', '2');

    insert into Matches_1841 (home_team_id, away_team_id, home_team_goals, away_team_goals) values ('6', '1', '0', '0');