Skip to content
Advertisement

Assign same group number for N-members in SQL Oracle

let’s say I have only one column of different codes, for example

I need to add new column with group number and I need it to be dynamic that means sometime I need 10 member group another time 5 member group so the output will be for 5 member group looks like this

of course I am able to to filter the codes so it could end up like this if I have 7 filtered codes

Advertisement

Answer

NTILE analytic function, I’d say. Sample data in lines #1 – 5, query begins at line #6.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement