码迷,mamicode.com
首页 > 数据库 > 详细

SQL查询列表中每种类型的第一条

时间:2017-03-25 15:47:31      阅读:340      评论:0      收藏:0      [点我收藏+]

标签:ttext   desc   row   mil   new   cli   port   style   where   

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

SQL查询列表中每种类型的第一条

标签:ttext   desc   row   mil   new   cli   port   style   where   

原文地址:http://www.cnblogs.com/CandyHY/p/6617032.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!