Question

Each employeeID has different network and customer.SoI want to have row number partitioned by network and Customer per EmployeeID.

I tried the below code but it still gives same rownumber for an employee even if network and customer are different.

select distinct ROW_NUMBER() OVER(PARTITION BY Network,CU,EmployeeiD ORDER BY Network,CU,EmployeeID)

I want 1,2,3 row numbers for an employee1 if he has 3 networks and also 1,2,3,4 for employee2 if he has 4 networks.

Can some one point me in right direction.

Thanks

Était-ce utile?

La solution

it still gives same rownumber for an employee even if network and customer are different

Because you are partitioning by network and customer as well. I think you want:

SELECT ROW_NUMBER() OVER(PARTITION BY EmployeeiD ORDER BY Network,CU)

That will give you the relative order of each record for each EmployeeID ordered (ascending) by Network first, then CU.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top