掏出5条热点新闻
取出5条热点新闻
USE [Publishing System ]
GO
/****** Object: StoredProcedure [dbo].[proghot5newsselect] Script Date: 05/12/2010 12:47:03 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: 韩慧
-- Create date: 2010-4-18
-- Description: 取出5条热点新闻
-- =============================================
ALTER PROCEDURE [dbo].[proghot5newsselect]
AS
BEGIN
select top 5 n.id,n.title,n.createtime ,c.name,c.id as caid,COUNT(com.id) as comcount
from news n
inner join category c on n.caid=c.id
left join comment com on com.newsid=n.id
group by n.id,n.title,n.createtime ,c.name,c.id
order by comcount desc
END