SQL查询列表中每种类型的第一条
SELECT * FROM NewsReport AS T WHERE ID IN
(SELECT TOP 1 ID FROM NewsReport WHERE TypeID=T.TypeID and IsDeleted = 0 ORDER BY ID DESC )
SQL子查询,类型名字,加分页
select * from (select ROW_NUMBER() over(order by CreateTime desc) as number,ID,Name, Img, ContentText, ClickCount, CreateTime,
(select Name from dbo.NewsReportType where Id=NewsReport.TypeID)as TypeName from NewsReport where IsDeleted = 0 )
as aaa where number between 1 and 10