select  pic_type,pic_id,sum(downs+notes) num
from pic
group by pic_type,pic_id
order by num desc 

解决方案 »

  1.   

    select  rownum 名次,pic_type,pic_id,sum(downs+notes) num
    from pic
    group by pic_type,pic_id
    order by num desc 
    这样可以吗
      

  2.   

    select pic_id, pic_type,downs,notes, dense_rank()over(partition by pic_type order by (downs+notes)) as 排名 from pic
      

  3.   

    SQL> select pic_id, pic_type,downs,notes, dense_rank()over(partition by pic_type order by (downs+notes)) as 排名 from pic;PIC_ID     PIC_TYPE                                     DOWNS                                   NOTES       排名
    ---------- ---------- --------------------------------------- --------------------------------------- ----------
    1002       1                                                2                                       5          1
    1004       1                                                4                                       5          2
    1001       1                                               10                                       6          3
    1006       1                                               10                                       6          3
    1003       2                                                2                                       7          1
    1005       2                                                6                                       5          26 rows selected
      

  4.   

    select pic_id, pic_type,downs,notes, dense_rank()over(partition by pic_type order by (downs+notes) desc ) as 排名 from pic;