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