-2

我有以下查询正在生成错误消息

消息 209,级别 16,状态 1,第 4 行不明确的列名称“p_id”

以下是有问题的查询。

SELECT *
from (select playerperform.p_id,player.first_name, SUM (playerperform.score)as totalgoal, RANK() OVER(ORDER BY SUM(playerperform.score)DESC) Rnk
      from playerperform,player  
      Group by p_id
      )as a
WHERE Rnk = 1
4

1 回答 1

1

显然,您在和p_id中都有一列。playerperformplayer

至少,改变:

GROUP BY p_id

GROUP BY playerperform.p_id

您正在执行隐式似乎也很可疑CROSS JOIN

FROM playerperform,player

我怀疑这应该是INNER JOIN有一些条件的,比如

FROM dbo.playerperform INNER JOIN dbo.player
ON playerperform.p_id = player.p_id

p_id顺便说一句,对于一个专栏来说,这是一个可怕的名字......

于 2013-10-25T15:59:47.977 回答