File size: 4,683 Bytes
02edc38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
/*
{
  "qid": "028",
  "task_type": "ambig",
  "has_intended_resolution": true,
  "language": "SQLite",
  "db": "professional_basketball",
  "question": "For each player and each team they played for in the 2007 season, show the post-season playoff status and games played.",
  "gold_ambiguity_points": [
    {
      "id": "A",
      "phrase": "post-season playoff status and games played",
      "type": "finite",
      "ambiguity_type": "syntactic_column",
      "interpretations": [
        "post-season playoff status and post-season games played",
        "post-season playoff status and all games played"
      ],
      "intended_interpretation_idx": 1
    }
  ],
  "gold_intended_query_id": "GQRY-A.1",
  "extra_info": {}
}
*/


----- START OF GOLD QUERY `GQRY-A.0` -----
/*
{
  "id": "GQRY-A.0",
  "parameter_names": [],
  "parameter_values": {},
  "other_exec_results": [],
  "required_columns": [
    1,
    2,
    3,
    4,
    5
  ],
  "required_sorted": false,
  "extra_info": {
    "ambiguity_resolution": {
      "[A] post-season playoff status and games played": "post-season playoff status and post-season games played"
    }
  }
}
*/
SELECT
p.playerID,
p.firstName,
p.lastName,
t.name,
t.playoff AS post_season_playoff_status,
SUM(COALESCE(pt.PostGP, 0)) AS post_season_games_played
FROM players_teams pt
JOIN players p ON pt.playerID = p.playerID
JOIN teams t ON pt.tmID = t.tmID AND pt.year = t.year
WHERE pt.year = 2007
GROUP BY p.playerID, p.firstName, p.lastName, t.tmID, t.name, t.playoff
ORDER BY p.lastName, p.firstName;
/* EXEC RESULT
 playerID firstName    lastName               name post_season_playoff_status  post_season_games_played
abdursh01    Julius Abdur-Rahim   Sacramento Kings                       None                         0
afflaar01     Arron     Afflalo    Detroit Pistons                         CF                        12
 agerma01   Maurice        Ager   Dallas Mavericks                         C1                         0
 agerma01   Maurice        Ager    New Jersey Nets                       None                         0
ahearbl01    Daniel      Ahearn         Miami Heat                       None                         0
... TRUNCATED ...
wrighlo02  Lorenzen      Wright      Atlanta Hawks                         C1                         0
wrighlo02  Lorenzen      Wright   Sacramento Kings                       None                         0
jianlyi01  Jianlian          Yi    Milwaukee Bucks                       None                         0
youngni01  Nicholas       Young Washington Wizards                         C1                         4
youngth01  Thaddeus       Young Philadelphia 76ers                         C1                         6
*/
----- END OF GOLD QUERY -----


----- START OF GOLD QUERY `GQRY-A.1` -----
/*
{
  "id": "GQRY-A.1",
  "parameter_names": [],
  "parameter_values": {},
  "other_exec_results": [],
  "required_columns": [
    1,
    2,
    3,
    4,
    5
  ],
  "required_sorted": false,
  "extra_info": {
    "ambiguity_resolution": {
      "[A] post-season playoff status and games played": "post-season playoff status and all games played"
    }
  }
}
*/
SELECT
p.playerID,
p.firstName,
p.lastName,
t.name,
t.playoff AS post_season_playoff_status,
SUM(pt.GP + COALESCE(pt.PostGP, 0)) AS all_games_played
FROM players_teams pt
JOIN players p ON pt.playerID = p.playerID
JOIN teams t ON pt.tmID = t.tmID AND pt.year = t.year
WHERE pt.year = 2007
GROUP BY p.playerID, p.firstName, p.lastName, t.tmID, t.name, t.playoff
ORDER BY p.lastName, p.firstName;
/* EXEC RESULT
 playerID firstName    lastName               name post_season_playoff_status  all_games_played
abdursh01    Julius Abdur-Rahim   Sacramento Kings                       None                 6
afflaar01     Arron     Afflalo    Detroit Pistons                         CF                87
 agerma01   Maurice        Ager   Dallas Mavericks                         C1                12
 agerma01   Maurice        Ager    New Jersey Nets                       None                14
ahearbl01    Daniel      Ahearn         Miami Heat                       None                10
... TRUNCATED ...
wrighlo02  Lorenzen      Wright      Atlanta Hawks                         C1                13
wrighlo02  Lorenzen      Wright   Sacramento Kings                       None                 5
jianlyi01  Jianlian          Yi    Milwaukee Bucks                       None                66
youngni01  Nicholas       Young Washington Wizards                         C1                79
youngth01  Thaddeus       Young Philadelphia 76ers                         C1                80
*/
----- END OF GOLD QUERY -----