In Oracle database, I have this data in a table:
| person | category | month | profit |
|---|---|---|---|
| John | A | Jun-1-2022 | 100 |
| Mary | A | May-1-2022 | 200 |
| John | B | Jun-1-2021 | 230 |
| John | A | Jun-1-2021 | 430 |
I need to add a new column into this table, called 'Same_month_last_year', which contains the data of same month last year. For example, John's data would be 430 for row 1.
I know a function in Oracle called ADD_MONTHS. but I'm new to programming (a finance student) and cannot seem to figure out how to use ADD_MONTHS to create this new column. Could you please advise?