急!!!得到下面结果的sql语句怎么写?谢谢!
记录如下:
NID NAME
1test1
2test2
2NULL
3test3
3NULL
需要得到查询的结果为:
NID NAME
1test1
2test2
3test3
[解决办法]
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 NID
drop table aa