+ -
当前位置:首页 → 问答吧 → SQL 查询问题

SQL 查询问题

时间:2011-12-04

来源:互联网

 有两个字段
  一个字段分类 class 另一个字 GoodsNamd
  怎么样在一个分类的第一行只显示分类,以后不显示

如:
 class   GoodsNamd
 酒    洋河
      大曲
      白干
 烟    中华
      双鼓
      老狼

作者: zqycn   发布时间: 2011-12-04

SQL code
select  
  case px when 1 then class else '' end as class,goodsnamd
from
  (select px=row_number()over(partition by class order by getdate()),* from tb)t

作者: fredrickhu   发布时间: 2011-12-04

SQL code
select 
Class=case when GoodsNamd=(select top 1 GoodsNamd from table1 where Class=a.Class) then Class else '' end,
GoodsNamd
from table1 as a

作者: roy_88   发布时间: 2011-12-04

热门下载

更多