Results 1 to 2 of 2

Thread: Query to go back to one year

  1. #1
    Junior Member
    Join Date
    Dec 2007
    Answers
    1

    Query to go back to one year

    Hi all,

    Our requirement, needs to display

    200708
    200707
    200706
    200705
    200704
    200703
    200702
    200701
    200612
    200611
    200610
    200609
    200608
    200607

    Starting from August is example only.
    we need to develop based on system date.
    From current month to we have to go back to one year.
    We prepared the query as follows.

    select to_char(sysdate,'yyyy')||to_char(a.b) b from (select rownum b from dual connect by rownum between 1 and 12) a

    It may give some idea.
    Plz try to send ASAP.

    Thanks,
    Suvarna


  2. #2
    Expert Member
    Join Date
    Apr 2007
    Answers
    500

    Re: Query to go back to one year

    Try this select to_char ( add_months (trunc(sysdate,'y'),rownum-1),'yyyymm') yyyymm from cat where rownum <= 12;


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact