记录如下:NID    NAME
1 test1
2 test2
2 NULL
3 test3
3 NULL需要得到查询的结果为:
NID      NAME
1 test1
2 test2
3 test3

解决方案 »

  1.   

    select * from [Table] where name is not null
      

  2.   

    --1、
        select * from 表名 where NAME is not null--2、
        select NID,max(NAME) from  表名 group by NID
      

  3.   

    不好意思,是这样的:
    NID    NAME
    1 test1
    2 test2
    2 NULL
    3 test3
    3 NULL
    4        NULL需要得到查询的结果为:(去掉那个重复的)
    NID      NAME
    1 test1
    2 test2
    3 test3
    4        NULL
      

  4.   

    create table aa(NID int,   NAME varchar(10))
    insert aa select 1, 'test1'
    union  select 2, 'test2'
    union  select 2 ,NULL
    union  select 3 ,'test3'
    union  select 3 ,NULL
    union  select 4  ,      NULL
    select NID,max(NAME) from  aa group by NIDdrop table aa