-1
CREATE TABLE Player
(playerID CHAR(3) ,
name CHAR(36),
year NUMBER,
team CHAR(50),
totalNoms NUMBER,
awardsWon NUMBER)

如何创建一个从数据库中的两列(球队和球员人数)中进行选择的查询?

4

3 回答 3

2

取决于你想要你可以做什么

select team, count(PlayerID) as NoOfPlayers
from Player
where team = 'Lackers'

或者

select team, count(PlayerID) as NoOfPlayers
from Player
group by team
于 2012-04-25T11:20:48.070 回答
1
 SELECT team,COUNT(playerID) As NoOfPlayers from Player group by team

在此处输入图像描述

于 2012-04-25T11:26:57.467 回答
0
Select distinct p.team, (
Select count(*) from Player where team=p.team
) 
from Player p

输出将是(例如):

  • 团队 1 25
  • 团队 2 34
  • 团队 3 11
于 2012-04-25T11:24:05.433 回答