From today's date, how to display last 10 years

I tried to do as much as I can in query, but when there are no records for corresponding year, year does not display.  But I would like the year to still display with a zero beside it.  So thought if there was a way, based from the
start date and end date, display current year and each year before that, no more than 10.

jhoward24's picture
Joined: Jan 11 2017 - 7:59am
Last seen: 2 years 1 month ago

4 Answers:

Try using this query if you are using Oracle

select trunc(extract(year from sysdate) - 0) + level - 10 as business_date
  from dual
connect by extract(year from sysdate) + level - 1 <
           extract(year from sysdate) + 10

reportdev's picture
10594
Joined: Oct 12 2015 - 12:05pm
Last seen: 9 months 2 weeks ago

Thanks so much for your help, but looks like I'm missing something.  I get the following error:

 "invalid relational operator"

jhoward24's picture
Joined: Jan 11 2017 - 7:59am
Last seen: 2 years 1 month ago

Be sure to maintain the same relational operators.. the same code works for me.

reportdev's picture
10594
Joined: Oct 12 2015 - 12:05pm
Last seen: 9 months 2 weeks ago

That works!  thanks so much reportdev! :)

jhoward24's picture
Joined: Jan 11 2017 - 7:59am
Last seen: 2 years 1 month ago
Feedback
randomness