I have got the set of data as follow
name date
x 2014-01-01
x 2014-01-02
y 2014-01-03
x 2014-01-04
and I'm trying to get this result
name date row_num
x 2014-01-01 1
x 2014-01-02 2
y 2014-01-03 1
x 2014-01-04 1
I have tried to run this query
select name,
date,
row_number () over (partition by name order by date) as row_num
from myTBL
but unfortunately I get this result
name date row_num
x 2014-01-01 1
x 2014-01-02 2
y 2014-01-03 1
x 2014-01-04 3
Please help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…