SELECT
top 2 t1.*,isnull(t2.[count],0) as [count]
FROM
Article t1
LEFT JOIN
(SELECT COUNT(C_Id) as [count],A_Id FROM Comment GROUP By A_Id) t2
ON
t1.A_Id=t2.A_Id
top 2 t1.*,isnull(t2.[count],0) as [count]
FROM
Article t1
LEFT JOIN
(SELECT COUNT(C_Id) as [count],A_Id FROM Comment GROUP By A_Id) t2
ON
t1.A_Id=t2.A_Id
使用查询达到了要求
但是我在使用存储结构的时候 出现了一个错误 错误 21037:[SQL-DMO] 在 Text属性的"CREATE... " 语句中指定的名称必须与Name 属性匹配,
而且后面必须跟有效的TSQL语句
这是怎么回事了!
asSELECT
top 2 t1.*,isnull(t2.[count],0) as [count]
FROM
Article t1
LEFT JOIN
(SELECT COUNT(C_Id) as [count],A_Id FROM Comment GROUP By A_Id) t2
ON
t1.A_Id=t2.A_Id
select A.*,(select count(*) from Command where A_Id=A.A_Id)
from Article A