表如下
file1   file2
上海     F2
上海     F1 
上海     F3
江苏     F4
我想得到结果是
file1   file2
上海     F1 
江苏     F4
就是把file1字段distinct,file2字段取的是最小的!

解决方案 »

  1.   

    select first_value(file1) over(partition by file1 order by file2) as file1
           first_value(file2) over(partition by file1 order by file2) as file2
    from tab
      

  2.   

    file2字段不用取最小,随便取一个也行
      

  3.   

    Eric_1999(╙@^@╜) ( )
    你写的语句好象没有distinct  file1
      

  4.   

    就是把file1字段distinct,file2字段取的是最小的!
    你自己写的。那这句:
    select file1, max(file2)
    from tab
    group by file1或select file1, min(file2)
    from tab
    group by file1