解决方案 »

  1.   

    真的不是广告啊,是发在百度贴吧了,CSDN估计上传我的问题的时候,解析到了什么语句,就像SQL里有'这个符号,是CSDN的bug,我就把那个问题发在别处了,大侠可怜可怜我吧
      

  2.   

    select * from tb t
    where not exists
    (select 1 from tb where t.点名 = 点名 and t.点编号>点编号)
    --这样可以不
      

  3.   

    select * from tb t where 点编号=(select min(点编号) from tb where 点名=t.点名)
      

  4.   

    6、7楼,你们考虑,经纬度值为NULL优先不为NULL的情况了吗?
      

  5.   

    create table tb(点编号 int,点名 nvarchar(10),坐标系统 nvarchar(10),经纬度 nvarchar(10))
    insert into tb select 1,'AA','北京54','123,23'
    insert into tb select 2,'AA','本地坐标',NULL
    insert into tb select 3,'BB','北京54','123,23.5'
    insert into tb select 4,'BB','本地坐标','123.5,23'
    insert into tb select 5,'CC','北京54',NULL
    insert into tb select 6,'CC','本地坐标',NULL
    go
    select * from tb where 点编号 in(
    select min(点编号) from tb 
    where 经纬度 is not null group by 点名   --找出某点名中经纬度不为NULL时的最小点编号
    union all
    select min(点编号) from tb a 
    where not exists(select 1 from tb where 点名=a.点名 and 经纬度 is not null)--找出某点名中经纬度全为NULL的最小点编号
    )
    /*
    点编号         点名         坐标系统       经纬度
    ----------- ---------- ---------- ----------
    1           AA         北京54       123,23
    3           BB         北京54       123,23.5
    5           CC         北京54       NULL(3 行受影响)*/
    go
    drop table tb
      

  6.   

    有一个小问题
    min(点编号)是适用于数字吧,我的编号其实是用的字符串