查 询 user表中 所有的 数据
但不能 让username  有重复的
谢谢了

解决方案 »

  1.   

    select username,max(字段1) as 字段1,max(字段2) as 字段2...
    from user
    group by username
      

  2.   

    create table a(name varchar(10), scot int)
    insert a
    select 'a',1 union all
    select 'b',1 union all
    select 'c',1 union all
    select 'd',2 union all
    select 'e',2select * from a t where [name] = (select max([name]) from a where t.scot=scot)
      

  3.   

    假设--
    表  :user
    字段:namename   
    aa
    aa
    bb
    ff得到
    name
    aa
    bb
    ff
      不知道LZ是不是这么意思。如果是的话sql如下:
    Select * from user as a  where not exists
       (select * from yonghu  where  a.name=user.name and a.id<user.id )
      

  4.   

    select 
        u.* 
    from 
        user u 
    where 
        username not in(select username from user group by username having count(*)>1)
      

  5.   

    declare @a table (name varchar(10), scot int)
    insert @a
    select 'a',1 union all
    select 'a',1 union all
    select 'b',1 union all
    select 'c',2 union all
    select 'e',2
    select * from @a a 
    where (select count(1) from @a where name=a.name)=1(5 行受影响)
    name       scot
    ---------- -----------
    b          1
    c          2
    e          2(3 行受影响)
      

  6.   

    是不是这样,a有两条记录以上不显示,只显示name只有一条的记录