USE AdventureWorks;
GO
SELECT SalesOrderID, SUM(LineTotal) AS SubTotal
FROM Sales.SalesOrderDetail sod
GROUP BY SalesOrderID
ORDER BY SalesOrderID ;
GO
给你个链接自己去看看关于group by 的用法
http://msdn.microsoft.com/zh-cn/library/ms189288.aspx
GROUP BY 语句中 SELECT中的东西必须包含在聚合语句里,或者是聚合函数,比如COUNT AVG MAX等。楼主的要求可以用
SELECT *,A.count FROM News INNER JOIN (select COUNT(*) AS count from News group by B_PKId ) AS A WHERE a.B_PKId = News.B_PKId