各位大牛问个查询产品表分类的问题

禁用F3 2015-09-25 06:51:04
如何查询产品表Type字段不同的值的数据各查询10条?同时带一个产品名称的模糊查询。
...全文
131 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
等不到来世 2015-09-28
  • 打赏
  • 举报
回复
select a.*
from 产品表 AS a,
(
	select id,rn=ROW_NUMBER() over(partition by [Type] order by ProductName)
	from 产品表
	where ProductName like '%香蕉%'
) AS b
where a.id=b.id and b.rn<=10
tomyuansir 2015-09-28
  • 打赏
  • 举报
回复
declare @A TABLE(type1 int,name varchar(2)) insert into @A select 1,'a' union select 1,'b' union select 1,'c' union select 1,'d' union select 2,'b' union select 3,'b' union select 2,'d' union select 3,'d' select * from ( select ROW_NUMBER() over(partition by type1 order by type1) id,* from @A )t where id<=10
tomyuansir 2015-09-28
  • 打赏
  • 举报
回复
declare @A TABLE(type1 int,name varchar(2)) insert into @A select 1,'a' union select 1,'b' union select 1,'c' union select 1,'d' union select 2,'b' union select 3,'b' union select 2,'d' union select 3,'d' select ROW_NUMBER() over(partition by type1 order by type1),* from @A order by type1,name
pengxuan 2015-09-26
  • 打赏
  • 举报
回复
给个表结构或数据,以及你想要的结果,把问题表述明白
双鱼星星 2015-09-25
  • 打赏
  • 举报
回复
需求不明确啊
哋岼線 2015-09-25
  • 打赏
  • 举报
回复
吧你的需求贴上来。这样讲很难帮忙你解决

34,593

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧