日期:2014-05-17  浏览次数:20886 次

请教以下语句如何改造成查询不重复记录
select rownum as rn,a.CALLID,a.CALLERNO,a.CALLEENO,to_char(a.CALLBEGIN,'yyyy-mm-dd hh24:mi:ss') beginTime,to_char(a.CALLEND,'yyyy-mm-dd hh24:mi:ss') 
endTime,a.RELEASECAUSE,a.DISTINCTION,a.CALLOUTCOUNT,a.CALLOUTSUCCESS, b.NAME
  from t_agent_latel_releasebillog a,customerinfo b where a.callerno=b.userphone order by begintime

因为是联表查询,想查询出所有b.name的不重复记录,并且按照begintime降序排列

------解决方案--------------------
row_number() over(partition by b.name order by a.CALLBEGIN desc) cnt
按name 分区(group by ) 时间倒叙,产生一个序列号。