【Oracle】数据库相关处理

  1. 多条重复字段取单个值

    select * from (
    select pog.orderno,
           pog.purchaseprice,
           pog.institutionno,
           pog.proxygoodsid,
           pog.seqno,
           pog.price_money, row_number() over (partition by pog.orderno order by pog.seqno desc) as group_idx  
              from PROXY_ORDER_GOODSPRICE pog) where group_idx=1 order by orderno asc

      

    --row_number() over (partition by pog.orderno order by pog.seqno desc) as group_idx--  对pog.orderno通过pog.seqno排序进行分组查询(pog.orderno重复,所以需要对pog.seqno排序取第一条)

版权声明:本文为liangayang原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。