I have a task in which I have to get a decade out of the year in a form (decade-'s), for example
1995 -> 90's
1983 -> 80's
2005 -> 00's
The last example is where the problem occurs because if I trim first two digits from a year which leaves me with 05 and then trim the 5 I get 0 which when casting to char turns to null value.
Here is my code:
SELECT arg1, arg2, arg3,
CONCAT(cast ( EXTRACT (year from date)%100 as varchar(1)),'0s') AS decade