sql - create serial numbers based on multiple columns -


i have following data

enter image description here

i want create index level shown in last column based on region, country, store type , location column. region column have own serial number each new region i.e. 'apac 1 , emea 2' same other columns(country, store type, location). have tried use partition result not able desired results.

use dense_rank() window function.

select *,        concat(         dense_rank() over(order region), ',',         dense_rank() over(partition region order country), ',',         dense_rank() over(partition region, country order [store type]), ',',         dense_rank() over(partition region, country, [store type] order location)        ) [index level]   tab 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -