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多条记录
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多条记录