【发布时间】:2009-12-18 15:57:22
【问题描述】:
我正在尝试内部连接 2 个临时表
我知道这可以做到,我以前做过,但我完全忘记了如何做到这一点
请告诉我
以下是我尝试执行的查询
select tmp1.*, tmp2.cnt from
(
select
1 as ClassificationType,
tblMatches.IdGame,
tblMatches.IdPlayer,
sum(Score) as Score, sum(Points) as Points, sum(OpponentScore) as OpponentScore,
count(ID) as MatchesCount, count(distinct IdCompetition) as CompetitionsCount
from
tblMatches
group by IdPlayer, IdGame
) as tmp1
inner join (select IdWinner, count(IdWinner) as cnt from tblCompetitions where IdWinner = tmp1.IdPlayer) as tmp2
on tmp2.IdWinner = tmp1.IdPlayer
这将失败
我想我不允许在创建 tmp2 的子查询中使用 tmp1
消息 4104,第 16 级,状态 1,第 17 行 多部分标识符 无法绑定“tmp1.IdPlayer”。
【问题讨论】:
标签: sql-server inner-join