我在SQL Server Management Studio 2014中具有以下选择语句:
SELECT main.car_descr
,vari.engineCode
,count(*) over(partition by vari.engineCode) as quant
FROM dbspareparts.dbo.stock as stock
inner join fiord.dbo.store as main on stock.[id_store]=main.[id_store]
where quant>2
order by quant desc
执行时,我在指令上得到“无效的列名”
where quant>2
为什么以及如何获得这项工作?
我需要使用count(*)over(...)语句,因为这只是另一个更长的查询的一部分。
谢谢!