Reputation: 77
My Data is like this -
You can check 3 columns, jil_equipment_id,req_group,operand. Based on these 3 columns i have to generate a new "Patern" Column.
The patern column is a patern and starts from 2 and increases by 1 for each repeated combination of jil_equipment_id,req_group,operand.
The final data will look like this.
Please suggest me any possible approach. I am not able to use the RANK()/DENSE_RANK() Function on this.
Upvotes: 0
Views: 33
Reputation: 8545
select *,Row_Number() over(partition by jil_equipment_id,req_group,operand order by jil_equipment_id,req_group,operand) + 1 as pattern
from tab
you can use row_number()
function for this.
Upvotes: 0
Reputation: 1271003
You can use row_number()
. You want to use the partition by
as well:
select t.*,
(1 + row_number() over (partition by jil_equipment_id, req_group, operand
order by content_id
)
) as pattern
from t;
Upvotes: 1