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