博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Oracle中: distinct会影响rownum

Posted on 2007-07-11 11:46  Snapping  阅读(1548)  评论(0编辑  收藏  举报
Oracle中:
distinct会影响rownum的约束条件。可能是先rownum, 然后再distinct的。

select   manager_id,manager_name
    from ( SELECT a.manager_id, a.manager_name, (sysdate-perf_score.max_perf_track_rec (c.track_record_id,'Q')) maxperf
              FROM gimd__manager a, gimd__strategy b, gimd__track_record c
              WHERE a.manager_id = b.manager_id
                    AND c.strategy_id = b.strategy_id
     --and ((null is null) or (b.PRODUCT_GROUP_CD = null))
            --and ((null is null) or (b.PRODUCT_CATEGORY_CD = null))
   )
  where
     lower(manager_name) like '%'||lower('s')||'%'
              AND RowNum <= 6;
得到6条记录;

select  distinct manager_id,manager_name
    from ( SELECT a.manager_id, a.manager_name, (sysdate-perf_score.max_perf_track_rec (c.track_record_id,'Q')) maxperf
              FROM gimd__manager a, gimd__strategy b, gimd__track_record c
              WHERE a.manager_id = b.manager_id
                    AND c.strategy_id = b.strategy_id
     --and ((null is null) or (b.PRODUCT_GROUP_CD = null))
            --and ((null is null) or (b.PRODUCT_CATEGORY_CD = null))
   )
  where
     lower(manager_name) like '%'||lower('s')||'%'
              AND RowNum <= 6;
得到3条记录


select  distinct manager_id,manager_name
    from ( SELECT a.manager_id, a.manager_name, (sysdate-perf_score.max_perf_track_rec (c.track_record_id,'Q')) maxperf
              FROM gimd__manager a, gimd__strategy b, gimd__track_record c
              WHERE a.manager_id = b.manager_id
                    AND c.strategy_id = b.strategy_id
     --and ((null is null) or (b.PRODUCT_GROUP_CD = null))
            --and ((null is null) or (b.PRODUCT_CATEGORY_CD = null))
   )
  where
     lower(manager_name) like '%'||lower('s')||'%'
得到20多条记录