首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

掏出5条热点新闻

2012-09-04 
取出5条热点新闻USE [Publishing System ]GO/****** Object:? StoredProcedure [dbo].[proghot5newsselect

取出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

热点排行