Latest 12 months

I have the following scenario, where I need data from the input data of the last 12 months.

Entry date is February 1, 2015, and must last 12 months data available in the table.

In the following query has given 1 February 2015 and the last 12 months after that date would be 1 February 14 February 1, 15.

But getting out of 1 March 14 to February 1, 15 (August record is missing in the data below)

with t as (
select to_date('1-DEC-2013') from_dt from dual UNION ALL
select to_date('1-JAN-2014') from dual UNION ALL
select to_date('1-FEB-2014') from dual UNION ALL
select to_date('1-MAR-2014') from dual UNION ALL
select to_date('1-APR-2014') from dual UNION ALL
select to_date('1-MAY-2014') from dual UNION ALL
select to_date('1-JUN-2014') from dual UNION ALL
select to_date('1-JUL-2014') from dual UNION ALL
select to_date('1-SEP-2014') from dual UNION ALL
select to_date('1-OCT-2014') from dual UNION ALL
select to_date('1-NOV-2014') from dual UNION ALL
select to_date('1-DEC-2014') from dual UNION ALL
select to_date('1-JAN-2015') from dual UNION ALL
select to_date('1-FEB-2015') from dual )
select * from t 
where from_dt between add_months(to_date ('1-FEB-2015') , -11)
and to_date ('1-FEB-2015')

August record is missing in the output because as its not available in the source. If you want to generate missing months and then filter the output then you can do it like this

SQL> with t as
  2  (
  3  select to_date('1-DEC-2013') from_dt from dual UNION ALL
  4  select to_date('1-JAN-2014') from dual UNION ALL
  5  select to_date('1-FEB-2014') from dual UNION ALL
  6  select to_date('1-MAR-2014') from dual UNION ALL
  7  select to_date('1-APR-2014') from dual UNION ALL
  8  select to_date('1-MAY-2014') from dual UNION ALL
  9  select to_date('1-JUN-2014') from dual UNION ALL
 10  select to_date('1-JUL-2014') from dual UNION ALL
 11  select to_date('1-SEP-2014') from dual UNION ALL
 12  select to_date('1-OCT-2014') from dual UNION ALL
 13  select to_date('1-NOV-2014') from dual UNION ALL
 14  select to_date('1-DEC-2014') from dual UNION ALL
 15  select to_date('1-JAN-2015') from dual UNION ALL
 16  select to_date('1-FEB-2015') from dual
 17  )
 18  select from_dt
 19    from (
 20            select add_months(from_dt, level-1) from_dt
 21              from (
 22                      select from_dt
 23                           , nvl(months_between(lead(from_dt) over( order by from_dt), from_dt), 1) month_count
 24                        from t
 25                   )
 26            connect
 27                 by level <= month_count
 28                and prior from_dt = from_dt
 29                and prior sys_guid() is not null
 30         )
 31   where from_dt between add_months(to_date('01-FEB-2015', 'DD-MON-YYYY'), -11)
 32                     and to_date('01-FEB-2015', 'DD-MON-YYYY');

FROM_DT
---------
01-MAR-14
01-APR-14
01-MAY-14
01-JUN-14
01-JUL-14
01-AUG-14
01-SEP-14
01-OCT-14
01-NOV-14
01-DEC-14
01-JAN-15
01-FEB-15

12 rows selected.

Tags: Database

Similar Questions

  • Display of the latest 3 month data

    Hi all

    I need disply current and last month 2 data.please let me know how to archive this.we use 11.1.1.6.10

    My requement like that

    Month name area SR

    June 22 Aaa

    BA July 100

    Aug his 210

    Thank you

    To_char OBIEE serves? You can go for current_date right?

    First test this logical query

    SELECT time. "' Saw_0 name of the month '"SERVICE - CRM Service Requests"WHERE the Time.Date <= cast(current_date="" as="" date)="" and="" time.date="">TIMESTAMPADD (SQL_TSI_MONTH,-(2), CURRENT_DATE) ORDER BY saw_0

  • Count of the number of months with unpaid for the last six months

    Hello

    I now table to store the daily presence of each employee

    ATTENDANCESHEET

    EMPID

    PAYROLLDATE

    UNPAID

    1

    10/01/2013

    6

    1

    10/02/2013

    2

    1

    11/01/2013

    0

    1

    11/02/2013

    0

    1

    12/01/2013

    0

    1

    12/02/2013

    0

    1

    01/01/2014

    0

    1

    01/02/2014

    0

    1

    02/01/2014

    0

    1

    02/02/2014

    0

    1

    03/01/2014

    45

    1

    03/02/2014

    0

    2

    03/01/2014

    0

    2

    03/02/2014

    0

    I want to get the number of months used unpaid in the past 6 months (excluding the current).

    If the month of payroll, I'm in treatment is 4, 2014, I spend 4 as payrollmonth and 2014 as payroll year

    The application must check the latest 6 month data and number of months for which there is any unpaid value

    In the case above for month 4, 2014, the power required is

    EmpID

    County

    1

    2

    2

    0

    I use oracle 10g

    EXAMPLES OF DATA

    create the table attendancesheet as

    (

    Select 1 as empid, to_date (January 10, 2013 ',' DD/MM/YYYY ') as payrolldate, 6 paid by union double all the

    Select 1 as empid, to_date (10 February 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (January 11, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (February 11, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (12 January 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (February 12, 2013 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (1 January 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (February 1, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (January 2, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (February 2, 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 1 as empid, to_date (3 January 2014 ',' DD/MM/YYYY ') as payrolldate, 45 paid by union double all the

    Select 1 as empid, to_date (3 February 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid by union double all the

    Select 2 as empid, to_date (3 January 2014 ',' DD/MM/YYYY ') as payrolldate, 0 as default all the double union

    Select 2 as empid, to_date (3 February 2014 ',' DD/MM/YYYY ') as payrolldate, 0 paid double

    );

    Help, please

    Hello

    So, you want to count the distinct months for 6 months before (not included) the given month; is this fair?

    Here's one way:

    VARIABLE month VARCHAR2 (2)

    Year VARIABLE VARCHAR2 (4)

    EXEC: months: = '4';

    EXEC: year: "2014"; =

    WITH got_end_date AS

    (

    SELECT TO_DATE (: month |) '/' || : year

    , ' MM/YYYY ".

    ) AS end_date

    OF the double

    )

    SELECT a.empid

    , COUNT (DISTINCT

    CASE

    WHEN a.unpaid > 0

    THEN TRUNC (a.payrolldate, 'MONTH')

    END

    ), Cnt

    Of attendancesheet one

    JOIN e-got_end_date WE a.payrolldate > = ADD_MONTHS (e.end_date-6)

    AND a.payrolldate< >

    GROUP BY a.empid

    ORDER BY a.empid

    ;

    If you use a WHERE clause to exclude the lines with some outstanding = 0 (or unpaid is NULL), then you would get no output for employees like empid = 2 in this example.  A WHERE clause ignores an entire line, so I used an expression BOX just a value.

  • Hi, if you cancel your monthly payments always keep the latest versions of the downloaded apps?

    Hi, if you cancel your monthly payments always keep the latest versions of the downloaded apps?

    You can use the files and open them in the apps but features may be limited.

    And the 30-day trial version.

  • I have a monthly subscription of photography should I continue getting the latest updates?

    Can I get the latest updates for Photoshop CC with the monthly subscription of photography?

    Yes.

    Up-to-date (20141 CC 2014.1.1 CC for example) often invite you to install them automatically.

    New upgrades of version (for example Photoshop CC 2015) must be installed separately through the cloud desktop application, whenever you are ready to install.

  • I pay for Adobe photography CC every month. I did the most recent downloads, but my Lightroom said always LR5. I don't understand? This is not the latest version of LR.

    I pay for Adobe photography CC every month. I did the most recent downloads, but my Lightroom said always LR5. I don't understand? This is not the latest version of LR. It also seems that adobe has made it more difficult to speak with a real human CSR.

    Since Lightroom 2015 CC is a new product, it will not show as an update to the previous. Click Install next to Lightroom in the creative Application of cloud Manager. If you do not see 'install' by Lightroom in the application manager, please first try to log out and return to: connect and disconnect from the creative cloud desktop application

    Guinot

  • I would like to install the latest version of Adobe Acrobat 6 computers. I wonder what tha cost, for a month and buy it directly? On a computer, we have version 9 and that is that we would uppgrade to the latest version?

    I would like to install the latest version of Adobe Acrobat 6 computers. I wonder what tha cost, for a month and buy it directly? On a computer, we have version 9 and that is that we would uppgrade to the latest version?

    Hi Linafrick,

    To install Acrobat 11 on 6 computers, you can purchase licenses in Volume.

    But since you want for only a month, you can buy a subscription Acrobat.

    A single subscription is good for 2 computers and the same Adobe ID can be used to buy multiple copies of Acrobat subscription.

    However, you can opt for creative license team cloud such that you can become the Admin and grant access to 6 users who wish to install Acrobat on their machines.

    Do not hesitate to contact our customer service via chat to find out more information: cloud creative membership support

    Kind regards

    Rave

  • Why am I not able to update the latest version of Firefox when it tells me that it is ready to download. It seems "stuck" on the connection to the update server and goes no further. This happens everytime I try for several months now.

    I think that the version he is trying to download is 10.something, and it seems to freeze on the window of 'progress' for quite awhile before I get it close. I've sometimes minimized the window while I did other things, coming to him perhaps 30 minutes later and the window is exactly the same as when I left it.

    You can try the alternative and easier way by downloading from here

  • Noticed a change some time ago - months. Now unable to access apple tv or download latest apple software update.

    getting the following message when you try to download the recent upgrades to itunes.  Now apple tv also does not work.

    .. .click on OK try again or enter a different path to the folder containing the installation package 'itunes.msi' in the box below...

    Tried all of the suggestions, including the search for the file. no luck. Any suggestions would be greatly appreciated.

    Some suggestions on troubleshooting

    iTunes for Windows in Windows XP or Windows 2000 does not open after upgrade
    http://support.Apple.com/en-us/HT203215

    Also: http://support.apple.com/en-us/HT203175

    J W Stuart: http://www.pagestart.com

  • Try to download adobe acrobat, but when I go to the Setup screen is this a compatibility issue. I have the latest installed so I don't know how to solve the problem. I just want to sign up for the monthly service to adobe acrobat. I have windows screws

    What is c? can someone help me out here? @

    Vista is no longer supported... Win 7, 8 or 10

  • How can I get 3 months free on Apple music?

    The situation is this: I applied to get the free subscription of three months for the students last night. I went through and checked my email, then discovered that I need to put a card on my account for making it happen. I did it the next day, however, I still cannot get the three month free subscription. It is not yet tell me that I joined Apple music that I thought that I did because of the subscription. There is nothing on my phone which is showing me or telling me where I can manage subscriptions. I've updated to the latest update from apple, and I don't know what is happening. Can I only manage subscriptions online or y at - it something to do with Apple music?

    Greetings rstevenson4,

    Thank you for using communities of Apple Support. It seems that you want to manage your subscription to Apple's music.  I recommend reading this article, it will show how to see and edit the subscription.

    Manage your membership Apple music on your iPhone, iPad, iPod touch, Mac or PC - Apple Support

    If you have joined Apple music, make sure that in settings > music, you have activated the Apple music. Take a look at the following article for more details on this subject.

    Join the Apple music on your iPhone, iPad, iPod touch, Mac or PC - Apple Support

    Take care

  • I downloaded the latest version of iTunes on my book Mac pro at the end of 2013.  Where is siri?

    I downloaded the latest version of iTunes on my book Mac pro at the end of 2013.  Where is siri?

    "the ability to play music using Siri when macOS Sierra launches this month ncluding"

  • Why can't Norton Identity Safe compatibility be integrated into the latest versions of Firefox? IE seems not to have problems with it.

    Firefox constantly asks me to upgrade to the latest version, which is not a problem as long as the new generation is compatible with applications that I serve throughout and rely on every day. I use the 40.0.3 version and it wants me to update to 41.0.2. If the Norton Identity Safe toolbar work with my current version of Firefox, what is the compatibility issue with a newer version of Firefox? IE does not appear to have this problem of update... which makes me consider the switch back to IE as my default browser. I rely on the Identity Safe to take care of my connection problems, and there is no need to deal with problems of incompatibility. I know I'm not alone in finding this aggravation with updates. (I use Win7 Home Premium, 64-bit).

    Sorry, this is a change in the types of code Add - ons are allowed to include. It was supposed to change in Firefox 40, but at the request of vendors such as Symantec, it was postponed to 41 of Firefox. I don't think this change will flip over. Norton is working on a new version, but I understand that it takes longer than expected.

    Here's what I suggest for users who need Norton password security features:

    Instead of freezing your Firefox on a non secure version, consider using the Extended Support Release (ESR). It is designed for businesses that require a cycle time longer between changes to the features, but anyone can use it. ESR is currently based on Firefox 38. It will get updates of security over the coming months, but not to get new features, so changes in Firefox 41 concerning the compatibility of the add-on will not be out for a good time.

    Norton is likely to continue to support the ESR until the new toolbar update is finished, maybe next month. After that, I don't know what they will do because normally they don't take over a small range of versions.

    If you decide to try it, here's how I suggest to install:

    Clean reinstall it

    We use this name, but it isn't about deleting your settings, this is to ensure that the program, files are clean (not incompatible, corrupt or exotic code files). As described below, this process does not disrupt your existing settings. Don't uninstall NOT Firefox, that does not need.

    (A) download a fresh Installer for Firefox 38.3.0esr of https://www.mozilla.org/firefox/organizations/all/ in an ideal location. (Scroll down your preferred language).

    (B) the release of Firefox (if any).

    (C) simply rename the program folder, either:

    (Windows 64-bit folder names)

    C:\Program Files (x86)\Mozilla Firefox
    

    TO

    C:\Program Files (x86)\Fx41
    

    (Windows 32-bit folder names)

    C:\Program Files\Mozilla Firefox
    

    TO

    C:\Program Files\Fx41
    

    (D) run the installer downloaded to (A). It should automatically connect to your existing settings.

    Success?

    Note: Some plugins can only exist in the old folder. If it is missing something essential, present in these files:

    • \Fx41\Plugins
    • \Fx41\browser\plugins
  • after update, the Favorites have disappeared. There is no automatic backup in the last 2 months. under the restoration, it gives me the possibility to restore until today.

    all of a sudden I have no Favorites.

    I read to all bookmarks, clikc backup and restore, restore and it will list the last 10 backups. the only listed backup is starting today, and no bookmarks are added when I restore

    I also saw to look on the desk in the old firefox files... most recent automatic backup was 2 months ago... it's too old

    I can't find the latest bookmarks files

    If you haven't tried stopping and restarting Windows because this problem occurred, I would suggest trying it. Some users have reported a problem after the updates of Windows where they see only partial information in Firefox, perhaps because of a problem of privileges.

    After that, if the problem persists, I'll ask you to verify a parallel settings folder. You can open the settings file (AKA Firefox profile) current Firefox help

    • button "3-bar" menu > "?" button > troubleshooting information
    • (menu bar) Help > troubleshooting information
    • type or paste everything: in the address bar and press Enter

    In the first table of the page, click on the view file"" button. This should launch a new window that lists the various files and folders in Windows Explorer.

    Make a note of the name of the current folder in the Windows Explorer address bar, and then click the 'profiles' word that appears before him to navigate a level and see if you find other profile folders here. If you check the inside, a folder bookmarkbackups in other profiles appear to be current?

    IMPORTANT: Do not use Windows System Restore feature — which can cause loss permanent data.

  • 5s short battery life iPhone, phone like new 6 months.

    I bought my iPhone about 6 months ago. I have problems with the battery life. I plug all night. Unplug in the morning and about 4 hours he spends 100% to 40%, even without me using the telephone. I thought to buy a new battery from Amazon and change myself. I found videos on YouTube showing how do, and it seems very easy to do. Someone out there chaned their own battery before? Was it easy to do? And your phone has worked for you once you have changed your battery yourself?

    Just thought I ask. I am one of these people if it's something I can do for my part, I do. Does anyone has an entry on the situation before I try this on my own?

    Hello

    The battery on the iPhone is not replaceable by the user. The battery - if that is the real problem - is covered by the limited warranty of one year of Apple.  If the iPhone is out of warranty, Apple also offers a service of the battery. The cost for this varies across countries (currently $79 in the United States, for example).

    However, as a first step, I suggest that you try to solve the problem of life battery. You can, for example, to consider measures such as:

    If the problem persists, I suggest you contact Apple technical support or make a Genius Bar reservation for assistance in identifying / confirming the issue and, if necessary, to set up your service from the available battery options, time and cost.

    To check your warranty status:

    More information:

    price of Service - Support Apple iPhone

Maybe you are looking for

  • the arrow buttons, page up/down buttons don't work in firefox 9 despite the function F7

    tried different settings in options/general. also tried on: config accessibility.warn_on_browsewithcaret without success. you provide the correct settings?

  • Portege Z930 - network WLan problems

    Z930 Windows 7 is 3 years old.I'm having problems connecting to the home network and I do not understand the clues to work towards a solution. Other laptops can connect to the wired network and wireless, but cant Z930, or down and will not show the h

  • Cannot RECEIVE in Windows Mail

    I get the error message: account: 'pophm.sympatico.ca', server: 'pophm.sympatico.ca', Protocol: POP3, Port: 995, secure (SSL): Yes, error number: 0x800CCC13 when you try to receive my email in Windows Mail for Vista. Depending on the issue recently p

  • OMG my mother owns the account main admin and how to take it down and pretend to the admin?

    OK so I have 2 admin accounts but then it was deleted I knew the password and now all I have is the main directly one and the im account on atm's as no admin privalleges how to reset the password for the admin PRINCIPAL that with only admin privalleg

  • WRT54GS V7 - no Internet connection

    Hi all I've had my router wireless for 3 years now. I recently moved and got my internet all together towards the top. I have not used my router in a year because my former ISP gave me a two in a router. Now that I'm with my current ISP (Time Warner)