If not object_id('[tb]') is null
Drop table [tb]
Go
Create table [tb]([ID] int,[P_TITLE] nvarchar(30),[P_COMPANY] nvarchar(50),[P_TIME] Datetime)
Insert tb
Select 1,'数据库','ORACLE_1','2009-08-06' union all
Select 2,'数据库','SQL SERVER 2000','2009-08-06' union all
Select 3,'数据库','SQL SERVER 2005','2009-08-06' union all
Select 7,'数据库','SQL SERVER 2008','2009-08-06' union all
Select 8,'操作系统','MS DOS','2009-08-06' union all
Select 9,'操作系统','WINDOWS 95','2009-08-06' union all
Select 12,'操作系统','WINDOWS 98','2009-08-06' union all
Select 14,'操作系统','WINDOWS 2000','2009-08-06' union all
Select 15,'操作系统','WINDOWS 2000 SERVER','2009-08-06' union all
Select 16,'操作系统','WINDOWS XP PRO','2009-08-06' union all
Select 17,'操作系统','WINDOWS 2003 SERVER ent','2009-08-06' union all
Select 18,'操作系统','WINDOWS 2008 ENT','2009-08-06' union all
Select 19,'列车','昆明-成都2003次','2009-08-06' union all
Select 20,'列车','昆明-成都2640次','2009-08-06' union all
Select 21,'列车','昆明-成都2650次','2009-08-06' union all
Select 23,'列车','昆明-成都K938次','2009-08-06' union all
Select 25,'列车','昆明-北京t62次','2009-08-06'
go
select [ID],[P_TITLE],[P_COMPANY],[P_TIME]
from (
select rn=(select count(1) from tb where id<t.id)/5,*,px=0
from tb t
union all
select distinct (select count(1) from tb where id<t.id)/5,null,null,null,null,1
from tb t
) as t
order by rn,px