日期:2014-05-18 浏览次数:20753 次
create table topic
(
Topicid int,
title nvarchar(10),
boardid int,
addtime datetime
)
insert topic select
1, 'abc', 100, '2007-1-1'
union all select 2, 'era', 101, '2007-1-2'
union all select 3, 'avx', 102, '2007-1-3'
union all select 4, 'zcv', 100, '2007-1-4'
union all select 5, 'jhv', 100, '2007-1-5'
union all select 6, 'ztw', 103, '2007-1-6'
union all select 7, 'xcv', 102, '2007-1-7'
union all select 8, 'zww', 104, '2007-1-8'
union all select 9, 'zqw', 105, '2007-1-9'
union all select 10, 'zti', 103, '2007-1-10'
select top 5 boardid from
(
select boardid,max(addtime) as addtime
from topic
group by boardid
) tmp
order by addtime desc