我是一个新代码,无法使用子查询来处理主查询数据。基本上我想从结果中计算出HP PC的数量。当我运行它时,我收到错误:无法绑定多部分标识符“dbo.softwareapplications.softwareid”。
select distinct appname, version, linkid,
(select count(make) as totalhp from dbo.workstations where make = 'Hewlett-Packard' and linkdid = t1.linkid)as totalhp
from dbo.softwareapplications as t1
join dbo.assignments on dbo.softwareapplications.softwareid = dbo.IQCSassignments.softwareid
join dbo.workstations on dbo.assignments.wsid = dbo.workstations.wsid
group by assetdescription, version, linkid, totalhp
任何帮助都将不胜感激。
答案 0 :(得分:0)
由于您将“dbo.softwareapplications”表别名为t1
,因此您必须在后续子句中引用它:
join dbo.assignments on t1.softwareid = dbo.IQCSassignments.softwareid
(或者,删除“as t1”别名和另一个对它的引用。)
答案 1 :(得分:0)
使用您创建的别名:t1.softwareid而不是dbo.softwareapplications.softwareid