我有一个这样的表 
标号  层号   数值   hs
1     A      0.2    ch
2     B      0.3    cb
                    cn
                    ch
                    cf
                    cn
我想实现这样一个查询语句,查询后的结果如下表
标号  层号      hs
1     A         ch
                ch
2     B         cb
                cn
                cn
                cf
就是把 hs中有相同值的写到一起(空值的不要),但这个字段下的值有可能还只有一个值,所以只要把 这一个值查询出来就行了 也就是这个字段下的值是不固定的我应如何实现这条查询语句,是不是应该把hs字段的值写到某个文件中
然后在查询 比较啊!             
             
            

解决方案 »

  1.   

    select 标号,  层号,     hs
    from 表 
    order by hs, 层号, 标号
      

  2.   

    select 标号,  层号,     hs
    from 表 
    where hs is not null
    order by hs, 层号, 标号
      

  3.   

    select *
    from 表 
    where hs is not null
    order by 层号, 标号
    group by hs
      

  4.   

    为什么这样查询出来的只是一条啊 !!!!
    空值的也会查询出来啊
    如果hs 只有一个值cn 
    hs
    cn
    cn
    cn
    空值
    cn
    查询出来的就是下面这样了
    hs
    cn
    空值
      

  5.   

    select *
    from a where hs is not null
    order by hs
      

  6.   

    象上面那样是满足了但
    这样把hs 为空值的也 查询出来了啊 
    不要空值啊!!!where hs is not null 这里已经限制了怎么会这样 啊
      

  7.   

    where hs is not null and hs<>''
      

  8.   

    where hs is not null and hs<>''
    这样写会出错的!

    007  我就是象你给我的那样写
    select *
    from a where hs is not null
    order by hs
    我在看看
      

  9.   

    where  hs  is  not  null  and  hs  <  >'''' 
    写成这样就好了 !!!可以了
    谢谢俩位了 啊