日期:2014-05-17 浏览次数:20572 次
create table [New_CommentInfo]
(
Id int identity(1,1) primary key
,[Pageid] int
,[Email]nvarchar(50)
,[Comment]nvarchar(512)
,[Addtime]datetime
,[Isdelete]int
)
insert into [New_CommentInfo] values(1,'xxx1@cc.com','1可以的。',GETDATE(),0)
insert into [New_CommentInfo] values(1,'xxx2@cc.com','3可以的。','2013-09-07 14:42:12',0)
insert into [New_CommentInfo] values(1,'xxx3@cc.com','2可以的。','2013-09-09 12:12:12',0)
create table [New_ReplyInfo](
[Id] int identity(1,1) primary key
,[Commentid] int
,[Email] nvarchar(50)
,[Reply] nvarchar(512)
,[Addtime] datetime
,[Isdelete] int)
insert into [New_ReplyInfo] values(1,'xxx2@cc.com','我也期待xxx2@cc.com',GETDATE(),0)
insert into [New_ReplyInfo] values(1,'xxx4@cc.com','我也期待xxx4@cc.com',GETDATE(),0)
insert into [New_ReplyInfo] values(2,'xxx4@cc.com','我也期待xxx4@cc.com',GETDATE(),0)
select tt.Pageid, tt.Email, tt.Comment,tt.Addtime
from (select t.Pageid,
t.Email,
t.Comment,
t.Addtime,
row_number() over(order by t.Addtime desc) rn
from New_CommentInfo t