Hi,
I have a question regarding Over(Partition by
This is a short description of my data.
Customer Id Product Id CreateDate
10 A 2020-01-01
10 A 2020-01-01
10 A 2020-01-01
10 B 2019-11-01
10 B 2019-11-01
20 A 2020-03-01
I need a query that shows the information as below;
Customer Id Product Id CreateDate SequenceNo
10 A 2020-01-01 1
10 A 2020-01-01 1
10 A 2020-01-01 1
10 B 2019-11-01 2
10 B 2019-11-01 2
20 A 2020-03-01 1
How can I write a query in SQL that shows the information above?
3 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sachin SinghPosted Nov 4, 2020, 7:32 AM
The DENSE_RANK function does not skip any ranks if there is a tie between the ranks of the preceding records, the rank is decided by the order by parameter passed inside Over , so you are trying to get same rank based on Created Date Column so you should use
Junaid MuslaPosted Nov 4, 2020, 6:56 AM
Nisha RegilPosted Nov 4, 2020, 6:19 AM