sql实现分组中并进行序号排序


sql:row_number() over(partition by xxxxxxxxxx order by yyyyyyyyyyyyy)

xxxxxxxxxx:分组字段;yyyyyyyyyyyyy:排序字段

select  
row_number() over(partition by d.area_code order by a.customer_name),  
a.customer_name, d.area_code 

from jc_customer as a
left join jc_province as b on a.province = b.province_name
left join jc_city as c on a.city = c.city_name and b.province_code = c.province_code
left join jc_area as d on a.area = d.area_name and c.city_code = d.city_code
order by d.area_code 

 

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM