Prior 12 Months

Hi ,
I have a table that contains the Oraganization ,Month and Year Columns .Kindly help with a query to retrieve Prior 12 Months From current month from the table data . Data example Like below
So for example current month is May year 2014 . As per the data its available only for the prior 9 months so 9 months should be displayed . In short maximum of 12 months and min depending upon the data available from the current month .
Oraganization  
Month 
Year
Xyz
9
2013
wed
10
2013
dfs
11
2013
gfh
12
2013
try
1
2014
uyuo
2
2014
edgvf
3
2014
wesdv
4
2014
srsfsr
5
2014
sdcdsfcx
6
2014
srrgvcvbb
7
2014
qwwfe
8
2014
Thanks
Priya

Please post DDL, so that people do not have to guess what the keys, constraints, Declarative Referential Integrity, data types, etc. in your schema are. Learn how to follow ISO-11179 data element naming conventions and formatting rules. Temporal data should
use ISO-8601 formats. Code should be in Standard SQL as much as possible and not local dialect. 
This is minimal polite behavior on SQL forums. 
Your rude narrative has a design flaw called “attribute splitting”; in Standard SQL, we have interval data types and that would mean that you want INTERVAL YEAR TO MONTH for one columns.
Microsoft is behind the standards. 
Since SQL is a database language, we prefer to do look ups and not calculations. They can be optimized while temporal math messes up optimization. A useful idiom is a report period calendar that everyone uses so there is no way to get disagreements in the DML.
The report period table gives a name to a range of dates that is common to the entire enterprise. 
CREATE TABLE Prior_Year_Periods
(month_name CHAR(10) NOT NULL PRIMARY KEY
   CHECK (month_name LIKE '[12][0-9][0-9][0-9]-[01][0-9]-00'),
 month_start_date DATE NOT NULL,
 month_end_date DATE NOT NULL,
  CONSTRAINT date_ordering
    CHECK (month_start_date <= month_end_date),
etc);
These report periods can overlap or have gaps. I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole calendar year. The advantages are that it will sort with the
ISO-8601 data format required by Standard SQL and it is language independent. 
Your report period is a month with an ending date 12 month ago. Your example is one row: 
INSERT INTO Prior_Year_Periods 
('2014-08-00', '2013-09-01',  '2014-08-31'),
Now use a simple BETWEEN predicate in your query. 
Here is my guess at what you should have posted. 
CREATE TABLE Foobars
(organization_name VARCHAR(25) NOT NULL PRIMARY KEY,
 foobar_month CHAR(10) NOT NULL 
  REFERENCES Month_Periods (month_name));
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL

Similar Messages

  • Want to schedule WebI report for End date of Prior Month

    Hello Experts,
    We have WebI report created on top of Bex Query, We have key date as prompt for the report. Can we schedule the webi report for key date as last date of prior month, so if current month is February, my key date should be Jan 30 2011. I am not sure if this is possible?
    Thanks,
    Ravi

    You need to apply two FM to get the end day of the month.
    First you need to apply FM MONTHS_PLUS_DETERMINE. This will give you the date after 3 months.
                CALL FUNCTION 'MONTH_PLUS_DETERMINE'
                  EXPORTING
                    MONTHS        = 3   " << for 3 months
                    OLDDATE       = l_start_Date   " << 12/01/2007
                 IMPORTING
                   NEWDATE       = l_3_Date. " << 02/01/2008
    Then call the FM RP_LAST_DAY_OF_MONTHS . this will give you the end date of the month
      CALL FUNCTION 'RP_LAST_DAY_OF_MONTHS'
        EXPORTING
          day_in            = l_3_Date  " << 02/01/2008
        IMPORTING
          last_day_of_month = l_3_Date  " < 02/29/2008
        EXCEPTIONS
          day_in_no_date    = 1
          OTHERS            = 2.
    Call both FMs again to get your another date(after 4 months).
    Regards,
    Naimesh Patel

  • Rate Lookup of prior month

    Hi experts,
    for a modified FX calculation I need the scanned month value and the corresponding FX rate. This is well handled by the LOOKUP command of Script Logic. In addition I need the prior month value and the corresponding prior month FX rate. I want to plan to achieve this by a second LOOKUP run that has this time shift by -1 period (=prior month).
    How would I code this in the Script Logic ?
    Environment: BPC 5.1, SQL Server 2005
    Any help is appreciated. Thanx.
    Regards.
    Wolfgang

    Hi Nilanjan,
    thanks for the quick response. Sorry, I have not understood what you mean exctly. Let's asuume we have a standard Rate Lookup, like the following
    *LOOKUP RATE
    *DIM ENTITY2="DEFAULT"
    *DIM SOURCECURR:INPUTCURRENCY=ENTITY.CURR
    *DIM SOURCECURR:INPUTCURRENCY="USD"
    *DIM RATE=ACCOUNT.RATETYPE
    *ENDLOOKUP
    *WHEN ACCOUNT.someproperty
    *IS "currentmonth"
    *REC(FACTOR=LOOKUP(DESTCURR1)/LOOKUP(SOURCECURR),CURRENCY="USD")
    *IS "priormonth"
    //* here I need the prior month FX rate 
    *REC(FACTOR=LOOKUP(DESTCURR1)/LOOKUP(SOURCECURR),CURRENCY="USD")
    *ENDWHEN
    where exactly do i need to place the PRIOR statement for the prior month FX rate ?
    Thanks.
    Regards.
    Wolfgang

  • Overage Charge for prior month on first bill

    Got my first Verizon bill today and found something interesting.  I was charged for going over my data for the prior month to the tune of $15 for a gig.  Problem is, I've only had the phone for a month and there is no prior month on my account!
    Or at least there shouldn't have been.  Looks like my billing cycle started the day after I got the phone, so all the data from setting up my phone in store was overage.  This is crap.  Anyone else notice this?

    That one day of the prior billing cycle was prorated based on the data plan you selected and divided by the number of days in the billing cycle.

  • Calculating prior months using off-set and crossing to prev year

    Gurus,
    I am getting current month period based on user entered value and calculating prior month by off-setting current month by 1.
    it works fine when current month value is greater than 1. If it is 1, prior month does get evaluated as 12 of previous year.
    Example...
    If Current period is - Feb, 2008 (02/2008). previous period comes fine as Jan, 2008.
    If current period is Jan, 2008 (01/2008) perious period is unknown. (I want it to be 12/2007).
    is there way to handle this without too much coding etc?
    Regards,
    -SM

    Mayank,
    What is SAP variable for Fical Year/Period, which will have both month and year value? (I guess I need to Fiscal posting period rather than Cal month?)
    Also what is SAP variable for Quarter/Year? I need to off-set of quarter also.
    Thanks, -SM

  • Find Prior Month Sales Per Salesman?

    I have salesmen throughout the country. Each salesman sells in a particular state. I want to total up each salesman's invoice sales for the prior month (I will also do this for: July 2010, %Difference between July 2011/July2010, YTD 2010, YTD2011, and percent difference between YTD2010 and YTD2011)
    The tables.fields I have are:
    ARSalesRep.Name
    ARInvoice.InvoiceDate
    ARInvoice.Invoicetotal
    ARInvoice.ShipToState
    How would I construct formulas for these?

    Hi, 
    A couple of ways you can do this: 
    1)  You can group on ARInvoice.ShipToState then on {ARSalesRep.Name}. 
    2)  Create 4 formulas and drop them into the Detail section: 
    YTD 2010
    If {ARInvoice.InvoiceDate} In [Date ((Year (Today) -1), 1, 1) to DateAdd (yyyy, -1, Today)] Then
         {ARInvoice.Invoicetotal}
    Else 0;
    YTD2011
    If {ARInvoice.InvoiceDate} In [Date ((Year (Today)), 1, 1) to Today] Then
         {ARInvoice.Invoicetotal}
    Else 0;
    July 2010
    If Year ({ARInvoice.InvoiceDate}) = (Year (Today) -1) And
         Month ({ARInvoice.InvoiceDate}) = Month (Today) Then
         {ARInvoice.Invoicetotal}
    Else 0;
    July 2011
    If {ARInvoice.InvoiceDate} In MonthToDate Then
         {ARInvoice.Invoicetotal}
    Else 0;
    3)  Right-click these fields and Insert Summary.  Drop the summarized fields into the  {ARSalesRep.Name} Group Footer.  You can hide the Detail section if you don't need to see it. 
    4)  Create a formula to calcuate the YTD difference using the summarized fields. 
    The other way would be to create a Crosstab report using the same formulas.  All depends on how you want to view your data. 
    Good luck,
    Brian

  • Display Net Outstanding Invoice amt only in Cust Statement for prior month

    Hi
    Our Client has requested for the Customer Statement to include only Net Outstanding Invoice balance for prior month while showing all transactions of Invoices and Payments including fully paid transactions for the current month only.  Currently they are not able to reconcile historical payments against Invoice because lots of them are partial payments only.
    Kedalene Chong

    Hello,
    Backdating of the statement is supported in 2007 A / 2007 B versions. Displaying fully
    paid transactions for the current month only will be considered for next release.
    Thanks for the valuable feedback.

  • Financial Reporting: Current Month vs Prior Month Variance for all Entities

    Silly/Easy Question:
    How can I set up a grid in Hyperion Financial Reporting to show these columns for all entities- Current Month NIBT, Prior Month NIBT, Variance
    So, the report would look like:
    Florida Current Month, Florida Prior Month, Florida Variance...Georgia Current Month, Georgia Prior Month, Georgia Variance...Ohio Current Month, Ohio Prior Month, Ohio Variance
    All I can get it to do at present is:
    Florida Current Month, Georgia Current Month, Ohio Current Month, Florida Prior Month, Georgia Prior Month, Ohio Prior Month, etc.
    Thanks!
    Note: we have many entities, so hard coding them in the report is out.

    Update: been working with Oracle dev on this. Seems FRS cannot produce a report such as this:
    ----------Entity-----------------------------------------Entity-----------------------------------------Entity
    ----------Curr Mo - Prior Mo - Variance----------Curr Mo - Prior Mo - Variance----------Curr Mo - Prior Mo - Variance
    Account
    Account
    Account
    Account
    Account
    The data can be extracted in other layouts, but this is one we'd like to utilize for Balance Sheet Variance analysis and Tax ETR reports.

  • Why are events being deleted in my history (prior months) on iCal?

    After downloading iCloud, I've noticed that any even scheduled in prior months has been deleted.  I like to keep this info for reference points in my business.  Can someone please give me advice on how to keep all past events on my Ipad / iCal?  And how can I restore these past events onto my iPad's iCal?  They are still showing up on the iCal on my iMac, which is really confusing!  Thank you!!!!

    sorry, "I've noticed that all the event scheduled in prior months have been deleted"....

  • Current Year & Prior Month

    Hello experts.  I tried a bunch of things, but I can't seem to get it right.  I want to get the format of my date like this: yyMM
    and have MM be the prior month.
    So, for 03/06/2015, I'd like to get this '1502'
    How can I do that?
    Knowledge is the only thing that I can give you, and still retain, and we are both better off for it.

    >>  I want to get the format of my date like this: yyMM .. So, for 03/06/2015, [gee, is that '2015-03-06' or '2015-06-03'?? ] I'd like to get this '1502' <<
    Why did you pick the worst possible local dialect for your display in the presentation layers? Google some articles on temporal data. This is more than SQL. 
    Since SQL is a database language, we prefer to do look ups and not calculations. They can be optimized while temporal math messes up optimization. A useful idiom is a report period calendar that everyone uses so there is no way to get disagreements in the DML.
    The report period table gives a name to a range of dates that is common to the entire enterprise. 
    CREATE TABLE Something_Report_Periods
    (something_report_name CHAR(10) NOT NULL PRIMARY KEY
       CHECK (something_report_name LIKE <pattern>),
     something_report_start_date DATE NOT NULL,
     something_report_end_date DATE NOT NULL,
      CONSTRAINT date_ordering
        CHECK (something_report_start_date <= something_report_end_date),
    etc);
    These report periods can overlap or have gaps. I like the MySQL convention of using double zeroes for months and years, That is 'yyyy-mm-00' for a month within a year and 'yyyy-00-00' for the whole year. The advantages are that it will sort with the ISO-8601
    data format required by Standard SQL and it is language independent. The pattern for validation is '[12][0-9][0-9][0-9]-00-00' and '[12][0-9][0-9][0-9]-[01][0-9]-00'
    --CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
    in Sets / Trees and Hierarchies in SQL

  • Sum prior month KF1 + KF2

    Hello,
    I am stuck in what seemed like a simple calculation...
    I have two key figures in my rows, and need to display fiscal year/month in the columns (requirements are for monthly totals across a rolling 24 months).
    As part of a bigger calculation, I need to add the following KFs and display the result in each of the 24 monthly column.
    prior month KF1 + KF2
    For example:
    Feb    = Jan KF1 + Feb KF2
    March = Feb KF1 + March KF2
    April    = March KF1 + April KF2
    ...etc.
    I have tried using RKFs and offset variables, but this just changes the months that are displayed in the columns.  Basically, I need for the value of KF1 for month X to "exist" in the following month's column.
    Help!

    Hi,
    I can see that you have a solution, but is it really working without a structure?
    I mean do you have your 2 KFs in the rows and then your CALMONTH in the drilldown accross the columns and then see
    KF1 = value for the month
    and KF2 = value for the previous month?
    please let me know because that would be new to me
    Olivier.

  • Prior month rate or data

    Hi,
    How can we access the prior month rate in the business rule table? If I use, say OPEAVG, it returns the AVG rate from the last month of the previous year. If I set the OPENING_PERIOD to -1 in the selected scenario, it doesn't seem to work.
    Thanks,
    Regis

    Note that I created a member "PAVG" in the RATE dimension and had a logic to copy the prior month AVG into the current month PAVG. This logic works fine but when I use PAVG in the Business Rule table, it converts at rate 0. However if I use a different name, say LMAVG as member name instead of "PAVG", then it functions.
    Somehow, "P" seems to be assimilated to the opening rate that corresponds to the average rate of the last month of the previous year.

  • Calc Status doesn't change on Prior Months...

    After I load metadata I "consolidate all with data" for December of a given year. Once this consolidation is finished the Calc Status of Dec is "OK" but when I look at any Prior Month within the same year the Calc Status is "OK SC" It is my understanding that consolidating any given month would consolidate all prior periods within the same Scenario/Year. Is there a way to fix this so the prior periods are consolidated as well?

    It would consolidate prior months if there was some change in the data for those months. Here, you have changed metadata therefore the status is "OK SC" which means that it is calculated/consolidated but there is a System Change (SC) since the last calculation/consolidation. HFM has no way to know whether you wanted to keep the calculations according to the previous version of your rules, so it does not execute consolidation for those periods. Bare in mind that rules may change from period to period due to changes in regulation (or more generally in the client's business needs) in contrast to the reason that the system is not yet finalized, which is probably your case at hand. In this case you must manually execute the consolidation for those periods.

  • What authorities do I need to start a dispute with for Verizon charging for "Unbilled Data From Prior Months - GB "

    For the second month in a row, Verizon has added a $15.00 "data over usage" fee.  When I call customer service, I am told that the charge is for over usage of data from prior months in which they can't tell me what months we went over.  We've been Verizon customers for 10+ years & all of a sudden their customer service has severely declined.  I am always on Verizon's website looking at our usage and the past 6 month analysis to make sure we're staying within our range of usage and we've never gone over our allowed plan for data.  I plan to file a formal complaint/dispute with all of the consumer protection agencies and/or authorities but need to know which ones are for telecommunications issues for Georgia consumers.

    For a customer of 10 years to never read the customer agreement...:
    "HOW AND WHEN CAN I DISPUTE CHARGES?
    If you're a Postpay customer, you can dispute your bill within 180 days of receiving it, but unless otherwise provided by law or unless you're disputing charges because your wireless device was lost or stolen, you still have to pay all charges until the dispute is resolved. If you're a Prepaid customer, you can dispute a charge within 180 days of the date the disputed charge was incurred. YOU MAY CALL US TO DISPUTE CHARGES ON YOUR BILL OR ANY SERVICE(S) FOR WHICH YOU WERE BILLED, BUT IF YOU WISH TO PRESERVE YOUR RIGHT TO BRING AN ARBITRATION OR SMALL CLAIMS CASE REGARDING SUCH DISPUTE, YOU MUST WRITE TO US AT THE CUSTOMER SERVICE ADDRESS ON YOUR BILL, OR SEND US A COMPLETED NOTICE OF DISPUTE FORM (AVAILABLE AT VERIZONWIRELESS.COM), WITHIN THE 180–DAY PERIOD MENTIONED ABOVE. IF YOU DO NOT NOTIFY US IN WRITING OF SUCH DISPUTE WITHIN THE 180-DAY PERIOD, YOU WILL HAVE WAIVED YOUR RIGHT TO DISPUTE THE BILL OR SUCH SERVICE(S) AND TO BRING AN ARBITRATION OR SMALL CLAIMS CASE REGARDING ANY SUCH DISPUTE."
    SEE FULL AGGREEMENT HERE: Customer Agreement | Verizon Wireless

  • How do I delete a prior month(s) or entire year(s) in iCal on my iMac (using version 4.0.4 (1395.7)?  Want to delete all months in 2009

    I checked what was previous asked in deleting months from iCal; however, that question pertained to removing events from a month and not necessarily deleting the entire month.  I have three years of calendars (January - December x three) in my iCal and want to delete all months for 2009 and 2010; however, I can't seem to find a way to delete.  I checked preferences/advanced under iCal but no mention of deleting previous months/years.

    Greetings Judith,
    Before making any attempts at deleting calendar data, backup what you have just in case:
    Click on each calendar on the left hand side of iCal one at a time highlighting it's name and then going to File Export > Export and saving the resulting calendar file to a logical location for safekeeping.
    iCal has an automated function located in iCal > Preferences > Advanced > Delete events "X" days after they have passed.  By typing in a value for days you can tell iCal to delete all events before that time frame.
    Example:
    Today is 4-16-2012.
    If I wanted to delete all events prior to 1 year ago (4-16-2011) I would type in "365" for the number of days.
    Once you type in the number of days you want kept in iCal, close the preferences and then quit iCal.
    Re-open iCal and check to see if the events are gone.  If not you may want to leave it open for several minutes and then quit again.
    Once the events are removed go back to  iCal > Preferences > Advanced > Delete events "X" days after they have passed and make sure the check mark is removed to prevent future deletion.
    Hope that helps.

  • Asset write-off in prior month.

    Is it possible to write off assets from an earlier month end date e.g the NBV of assets with a month end date of 31/05/09 or can you only write off within the current month?
    If this is possible, how will SAP deal with the depreciation and how will it charge any depreciation posted after that date?

    Hi Jeremy Lumb
    Yes you can retire an asset in prior period where depreciation has already been posted. The system will recalculate the total depreciation for year in the retirement year and make adjustments (positive value) in the next period. You can then run depreciation again so the adjusted value will be posted .
    Hope this helps.
    Thanks
    Sanjeev

Maybe you are looking for

  • Can not open drive

    can not open drive

  • Windows 8.1 on BootCamp WiFi Problem

    Hey, I installed Win 8.1 via BootCamp on my Macbook Pro late 2014. All is fine except WiFi .. It keeps dropping. When I run diagnostics it says "Default Gateway Not Available" and it resets the wifi adapter. And it fixed it for 15-20-30 minutes and t

  • Seeburger File/VAN adapter

    Hello, Is it possible to use a File/VAN adapter from Seeburger for simple ftp scenario, without connection to a VAN? How do I configure the adapter parameters? Many thanks! regards, Erik

  • Bridge CC scrolling - Jumps. Not smooth.

    Scrolling in all windows (folders, metadata, filter...ect) but the Content window results in jumping rather than a smooth scroll. Latest update didn't fix this so I am still forced to use CS6 OSX 10.9.4 Magic Mouse anyone else have this problem? anyo

  • Plese help on AD-HOC query

    hi experts,    plaese give the step by step procedure to for creating Ad-hoc query & what is the use of Ad-hoc query.I have seen some Threads but i didnt get . so please give me step by step procedure .     If anybody having screen shots please send