A表:
a     b     c
------------------
a1    b1    1
a1    b2    2
a2    b3    3
a2    b4    4
a3    b5    5我想要的查询结果是,过滤 a 列的重复数据,并且按 c 列来排序a  
----
a3
a2
a1请问该 怎么实现。
谢谢。

解决方案 »

  1.   

    select distinct a
    from A表
    order by a;
      

  2.   

    哦是低序select distinct a
    from A表
    order by a desc
      

  3.   

    select distinct a 
    from A表 
    order by c;select distinct a 
    from A表 
    order by c desc;
      

  4.   

    BenChiM888的有错误啊。不是SELECTed表达式。
      

  5.   

    如果以C,则楼主需要定义清楚你按照哪个C排? 比如下面这个顺序是什么?A表:
    a   b   c
    ------------------
    a1  b1  1
    a2  b3  2
    a2  b4  2
    a3  b5  3
    a1  b2  4
      

  6.   

    ACMAIN_CHM   我不太清楚  你说的按照哪个 C 排,这句话是什么意思。C列中没有重复的值。可不可以  先查询出 过滤掉重复A的列,和 C列,然后再按C 来排序呢?select a,c from (select distinct a,c from A表) order by c desc   ????select distinct a,c from A表     这句话过滤不掉重复的, 请教。。
      

  7.   

    如果按a对应的最大的c来排:
    select t.a from (select a,max(c)as c from tbl group by a) t order by t.c desc;
    如果按a对应的最小的c来排:
    select t.a from (select a,min(c)as c from tbl group by a) t order by t.c desc;
      

  8.   


    抱歉select a from(
    select a,max(c) c
    from A表
    group by a)
    order by c;select a from(
    select a,max(c) c
    from A表
    group by a)
    order by c desc;