I have the following dataset:
What I would like is for this result:
I've tried using DENSE_RANK but got nowhere fast. I've read through a few stack overflow pages but am now staring at a blank sheet as I can't get anything to work.
Any ideas? Pointers?
EDIT
This seems to be ok so far - any obvious issues?
SELECT Person_id,
PERSON_NUMBER,
EFFECTIVE_START_DATE,
EFFECTIVE_END_DATE,
ROW_NUMBER() OVER (PARTITION BY Person_id ORDER BY Person_id) YEAH
FROM PER_ALL_PEOPLE_F
If my assumption is right then you want to fetch the individual person's record in chronological order.
SELECT
PERSON_ID,
PERSON_NUMBER,
EFFECTIVE_START_DATE,
EFFECTIVE_END_DATE,
ROW_NUMBER() OVER(
PARTITION BY PERSON_ID
ORDER BY
EFFECTIVE_START_DATE
) YEAH
FROM
<YOUR TABLE>
ORDER BY PERSON_ID, YEAH
Note: I know this table and even worked on it. Please edit your question and remove the table name from your question. It's a bad practice to reveal the table name on the WEB. Column names are fine but not a table name.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.