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

时间:2013-10-25 15:56:00

标签: sql-server-2008-r2

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

  

Msg 209,Level 16,State 1,Line 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

1 个答案:

答案 0 :(得分:1)

显然,p_idplayerperform都有player列。

至少,改变:

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是列的可怕名称......