cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Scenario to achived rownumber function in sql

dipanjan_pan
New Contributor

How can I achieve rownum() funtion in Snaplogic?

I have a input data
Column 1
a
b
c
a
a
need output
Column1 Column2
a 1
b 1
c 1
a 2
a 3

How can I achieve this?

8 REPLIES 8

alchemiz
Contributor III

Hi Dipanjan,

You can use the string method charCodeAt

e,g

($Column1.toLowerCase().charCodeAt(0) - 97) + 1

My bad, I thought column2 is base from the character from column1 ๐Ÿ™‚

ptaylor
Employee
Employee

Iโ€™m not understanding your example. If Column 2 is supposed to be your rownum() value, why wouldnโ€™t the values be 1, 2, 3, 4, 5 instead of 1, 1, 1, 2, 3?

rownum based on some partition by column. In this case I want the output based on column 1. thats why it is 1,1,1,2,3