表结构如下:name total  hit
a    b      23
a    b      32
c    f       5
..........现在要求如下:输出
name  totalname和total组合不能重复a     b
a     c
a     sf
a     fsf
b     b
b     afa
b     sdfsf
.......

解决方案 »

  1.   

    select name  total from 表名
    group by name  total
      

  2.   

    create table tbl(name nvarchar(10),total nvarchar(10),hit int)
    insert into tbl select 'a','b',23
          union all select 'a','b',32
          union all select 'c','f',5
          union all select 'c','f',4
    select * from tblselect distinct name,total from tbl drop table tb
    --------------------
    a b
    c f
      

  3.   

    我好像自己也是第一楼的写法.不知道有什么问题select distinct(name ) from table  就像这种效果,只是我这儿是两个字段不能重复/
      

  4.   

    就是name total这两个字段不能重复,但是单个字段可重复