Reputation: 79
I have table like this:
CustomerID | Trans_date |
---|---|
C001 | 01-sep-22 |
C001 | 04-sep-22 |
C001 | 14-sep-22 |
C002 | 03-sep-22 |
C002 | 01-sep-22 |
C002 | 18-sep-22 |
C002 | 20-sep-22 |
C003 | 02-sep-22 |
C003 | 28-sep-22 |
C004 | 08-sep-22 |
C004 | 18-sep-22 |
I would make a new column consist ISO week
CustomerID | Trans_date | Week_ISO |
---|---|---|
C001 | 01-sep-22 | 35 |
C001 | 04-sep-22 | 35 |
C001 | 14-sep-22 | 35 |
C002 | 03-sep-22 | 35 |
C002 | 01-sep-22 | 35 |
C002 | 18-sep-22 | 35 |
C002 | 20-sep-22 | 35 |
C003 | 02-sep-22 | 35 |
C003 | 28-sep-22 | 35 |
C004 | 08-sep-22 | 36 |
C004 | 18-sep-22 | 36 |
But i can't make because there's not have datepart
Upvotes: 0
Views: 78
Reputation: 13049
You can define a view instead of altering the original table. Use extract or date_part.
create or replace view the_view as
select customerid, trans_date,
extract('week' from trans_date) week_iso
from the_table;
Upvotes: 1