CREATE TABLE Player
(playerID CHAR(3) ,
name CHAR(36),
year NUMBER,
team CHAR(50),
totalNoms NUMBER,
awardsWon NUMBER)
如何创建一个查询,从数据库中选择两列(团队和队员)?
答案 0 :(得分:2)
取决于你想要做什么
select team, count(PlayerID) as NoOfPlayers
from Player
where team = 'Lackers'
或
select team, count(PlayerID) as NoOfPlayers
from Player
group by team
答案 1 :(得分:1)
SELECT team,COUNT(playerID) As NoOfPlayers from Player group by team
答案 2 :(得分:0)
Select distinct p.team, (
Select count(*) from Player where team=p.team
)
from Player p
输出将是(例如):