partition by相比较于group by,能够在保留全部数据的基础上,只对其中某些字段做分组排序(类似excel中的操作),
row_number() over()分组排序功能
select * from(
select * ,row_number() over(partition by propertyNo order by case when agentType='SHARE' then 1 when agentType='BROWSE' then 2
when agentType='INVITE' then 3 when agentType='VISIT' then 4 when agentType='SURVEY' then 5
when agentType='FOLLOW' then 6 end) rn from T_AgentTohouse ) tn where tn.rn=1