How to subtract the different monthly amounts of the same column

Hi all

I'm creating a quarterly report to display purchase against 13 weeks orders (same quarter courses there will be US 13 weeks).

First month 4 weeks, 2 months 4 weeks and 3 months was 5 weeks all the time. I have a data dimension table that will tell me the number of the week (Col1 Eg; 1, 2, 3) and the number of months (col2 Eg):

01/11/2013

01/12/2013

01/01/2014

) this week belongs to...

My data;

Month week in.

01/11/2013 1 100

01/12/2013 5 50

01/01/2014 9 110

Desired output:

MonthWeekPO
01/11/20131100
01/11/20132100
01/11/20133100
01/11/20134100
01/12/20135100 50
01/12/20136100 50
01/12/20137100 50
01/12/20138100 50
01/01/20149-110 (100-50)
02/01/201410-110 (100-50)
03/01/201411-110 (100-50)
04/01/201412-110 (100-50)
05/01/201413-110 (100-50)

My version of oracle's Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64 bit.

Thank you

Hello

Using the response code that I have posted on your previous post, here's a way to do:

WITH bucket AS (
  SELECT date '2013-11-1' mon, 100 po  FROM dual UNION ALL
  SELECT date '2013-12-1' , 50 FROM dual UNION ALL
  SELECT date '2014-1-1' , 110 FROM dual
),
mm AS (
SELECT
  mon, po,
  rownum month_no,
  CASE
    WHEN rownum=1 THEN po
    ELSE LAG(po, 1, 0) OVER (ORDER BY mon) - po
  END po_diff
FROM bucket
),
week AS (
  SELECT rownum n FROM dual CONNECT BY level <= 5
)
SELECT mon "Month",
  ROW_NUMBER() OVER (ORDER BY mon,n) "Week",
  n wk,
  po_diff "PO"
FROM week, mm
WHERE month_no = 3
OR (month_no IN (1,2) AND n <= 4)
ORDER BY month_no, wk ;

Tags: Database

Similar Questions

  • How to find the same column name in different tables in the same schema

    Hello

    I find the 'ename' column name in different tables in the same schema.

    Thank you
    Nr

    Hello

    Try this query

    Select column_name, table_name from user_tab_columns where column_name = 'ENAME ';

    Award points and end the debate, if your question is answered or mark if she was...

    Kind regards

    Lacouture.

  • How to map the same tag of the element with a different value in BI Publisher rtf model.

    Hello

    I have an xml file with the same name in the < tag > element and I do not know how to associate the same < tag > element to different string in the document rtf template attribute.

    For example: "' Eswitch <number > is repeated in this xml file, when I am mapping this element to the document rtf with a different string, I have same value 'D00002 ' . I should get values D00002 and DMR00002.

    < document >

    < TitleBlock >

    < number > D00002 < / number >

    < itemType > Document < / itemType >

    < lifecyclePhase > preliminary < / lifecyclePhase >

    < description > gtedgg < / description >

    < shippableItem > n < / shippableItem > < / cartridge > < / Document >

    < DMR >

    < TitleBlock >

    < number > DMR00002 < / number >

    < itemType > DMR < / itemType >

    < lifecyclePhase > preliminary < / lifecyclePhase >

    test nomenclature model bom1 < description > < / description >

    < POS > < value > Test < / value > < / POS >

    < shippableItem > n < / shippableItem > < / cartridge > < / DMR >

    < / AgileData >

    I followed steps below for map document model rtf with the same tag xml with a different value.

    1. install Office word 2013.

    2 BI Publisher for desktop software installed. It will add a BI Publisher plugin to the word document.

    3. with the help of desktop publisher BI, created a model of document rtf file.

    4 imported the document rtf template example xml file.

    The data is loaded successfully.

    5 tires model rtf field symbol to map the tags to xml to rtf document attributes element.

    7 saved the document in PDF format.


    Thank you

    Please mark it correct so that it is useful for others to find the solution to a similar request.

  • How to subtract the DATE CURRENT SYSTEM and tire of Siebel

    Hi Experts,

    How to subtract the date of DAY and Date, which came in Siebel?

    Example:
    The DAY - Date records in Siebel

    Current date = 25/11/2012
    Registration date in Siebel = 20/11/2012

    Technically the answers I want will be 5.
    How can I do this? My idea is to put a phrase in the MDB layer, but I want to just get your ideas:

    Current_Date - "Oracle Data Warehouse. "'"' Catalogue'."" """dbo"."" TABLE_NAME ". "' COLUMN_NAME '.


    Thank you!

    Hello

    You can use the available in OBIEE timestampdiff function to get the difference between two dates. This is one of the blogs that can help with the syntax.

    http://Shahin-OBIEE.blogspot.in/2012/04/various-calculations-for-date_16.html

    You can also google timestampdiff function for details on usage and syntax.

    Thank you

  • A target table is in charge of two different sources but the same columns, but a source is one database and another in a flat file.

    We all hope you are doing well.

    I have a business problem to implement in ODI 11 G. It's here. I'm trying to load a target table from two sources that have the same column names. But a source is to the file format and the other is in the Oracle database.

    That's what I think I'll create two mappings in the same interface by using the Union between the sources. But I don't know how the interface would connect to different logical architecture to connect to two different sources.

    Thank you

    SM

    You are on the right track, all in a single interface. Follow these steps

    (1) pull model of your data in the designer of the source file and your table model target to the target pane.

    (2) all relevant columns map

    (3) in the source designer to create a new dataset and choose as the UNION join type (this will create a separate tab in the source designer pane)

    (4) select the new dataset tab in the source designer pane and pull your source oracle table data model in the designer of the source. All columns that are relevant to the target card

    (5) make sure that your staging location is set to a relational technology i.e. in this case the target would be an ideal candidate because it is where the ODI will organize the data from source two files and oracle and perform the UNION before loading to the target

    If you want to watch some pretty screenshots showing the steps above, take a look at http://odiexperts.com/11g-oracle-data-integrator-part-611g-union-minus-intersect/

  • By subtracting the values in the same column?

    Hello

    How can I subtract two values in the column of the table. EG - there is a table with two columns with date and cumulative turnover.

    Date Total_sales
    ===== =======
    February 23, 68
    24 feb-122
    25 feb-150
    26-Feb-200
    27 feb-223

    I need to know about the date that sales have been maximum. As we can see on 24 - Feb, sales were 54. We do this by subtracting 122-68.
    How can subtract us values in the same column?

    Thank you

    Take a look at the lag() of analytic SQL function which should give you what you need.

    See you soon,.
    Harry

  • an alphabet by typing in a cell gives drop down suggestions from previous hits on the same column. But how the drop down to choose the suggestions of the other columns and other sheets.

    an alphabet by typing in a cell gives drop down suggestions from previous hits on the same column. But how the drop down to choose the suggestions of the other columns and other sheets.

    Hi mdsavol,

    Your observations are accurate. The 'suggestions' are previous entries in the same column that correspond to what has been entered so far in the active cell. The only direct user control is to activate the function turn on or off in numbers preferences > general.

    There are other ways to include or exclude items of suggestions:

    • To remove typos in the suggestions list, the user must correct the typos in the cell above the active cell. If they are more in the list, they won't be presented as suggestions.
    • To include selections added to the list, the user must enter these suggestions in the individual cells above the active cell and column where they are wanted as suggestions.

    There was a request here a while there is a list of suggestion 'live' similar to those of some websites, which offers a descending list of possible entries as a type in an input box.

    The only way I see to reach a solution similar to what you have asked is to use as many lines at the top of the non-en-tete of the table section to list the items likely to repeat in your table, and then hide the lines. You'll need a list for each column where you want to use this feature with a list previously planted. Existing items will then require a likely hit up to three, then a click to choose from a list small enough to enter a value into a cell. News he will need to enter in full the first time, but after that it will be put on the list and answer the same thing as the terms preseeded.

    While your setting upward (or decide not to do), consider going on the menu of number (in numbers), choosing to provide feedback from numbers and writing a feature in Apple request. Describe what you want. Explain how he could help the average user numbers, and then hope for the best.

    Kind regards

    Barry

  • I made my largest site and how can keep the same size for all other sites?

    I did the 2 larger site and how to keep the same size for all pages when I re - open the web browser?

    You can use an extension to set a page zoom and the size of the default font on the web pages.

  • How to put the 2nd column 1st column in excel

    Hello

    I have a question how to set the 2nd column 1st column in excel. Thank you.

    Why the 1 iteration for loops?

    Why two Index tables?  He's just trying to solve the problem created by the loops For on the original 1 d arrays.

    Two of these things create 2D tables which are what complicates things and can be eliminated.

    You can take your 2 1 d tables, use build table and right-click to set 'concatenate the inputs.

    If you have a 2D array, you can use table remodel to make a 1 column of the table of N line 2D.

  • How to read the two columns of data from the Port series

    Hello

    I'm reading two columns of data from the serial port.

    Example:

    52439 52430

    52440 52437

    52209 52214

    51065 51070

    52206 52390

    I use the serial of Visa service and I can read the first column of data from the serial port, but I can't understand how to read the second column.

    I want to both sets of chart data.

    I enclose my VI.

    Thank you for your help.

    The analysis of string function takes a "Format string" on top (with the right button of the function and choose Help, which explains all the entries).  In particular, you can say 'Give me two numbers separated by a tab' and the output will be two numbers (whole or floating, depending on the chosen format).  In particular, %d\t%d specifies a decimal integer, , whole decimal.

  • Columns of folder: by default, how can return the first column 'Name' without having to move it manually every time?

    Something's happened awhile and when I create a folder which appears the first column is the column 'Date modified '. By default, how can return the first column 'Name' without having to move it manually every time?

    Hello

    I suggest you to visit these links and check if it helps:

    http://Windows.Microsoft.com/en-us/Windows-Vista/working-with-files-and-folders#section_4

    http://Windows.Microsoft.com/en-us/Windows-Vista/folders-frequently-asked-questions

    It will be useful.

  • How to display the comments column in Windows Media Player 12?

    WMP12 - how to display the comments column?

    I want to see the Cooments ColonneB in my WMP ads, but it is not giving me the option.

    Hello

    1. What do you mean exactly by the column comments?
    2. are you referring to in Windows Media Player?

    If you want to change the information contained in the Windows Media Player, you can follow the steps in this article.

    http://Windows.Microsoft.com/en-us/Windows7/add-or-edit-media-information-in-Windows-Media-Player

  • How to add the new column in existing table to our desired location?

    How to add the new column in existing table to our desired location?

    For example, I have to add the new column 'course' before the salary column in the emp table.

    I think the best way is to add the column at the end of the table and create a new view with the order of the columns...

    Another option...

    places the data into a temporary table and recreate the table with the correct order of the columns, and then insert data to the table from the temporary table

    Refer

    Add column (from table) in the desired position

    Example:

    CREATE TABLE temp_my_user LIKE)

    SELECT * FROM password);

    DROP TABLE password;

    (Password) CREATE TABLE

    userID NUMBER

    , first name VARCAHR2 (25)

    , middleInitial VARCHAR2 (1)

    (, name VARCHAR2 (25));

    INSERT INTO password (userID, firstName, lastName)

    (SELECT username

    first name

    lastName

    OF temp_my_user);

    DROP TABLE temp_user;

  • How to make the same effect of scrolling like Tumblr (beginning Web page) with Adobe Muse?

    How to make the same effect of scrolling like Tumblr (beginning Web page) with Adobe Muse?

    I used Adobe Muse since the day it first came out, I played with the timings and effects of scrolling a lot. Tumblr landing page scrolling is very nice, I can see why you want a similar effect. Something similar could be created using the scrolling in AdobeMuse effects, especially if you familiarize yourself with the scrolling of the transparency. Start with a color block simple try it scroll up to double speed, then add items to the next page with the scrolling transparencies. Best practical work, use layers to do this, it makes things so much easier when you need to edit the page.

    Once you have played with the effects of scroll, you will begin to note how the elements of the Tumblr page can be re-created. This will be a sharp learning curve, but very doable in Muse for a similar effect. You will have a number of layers with page elements and new blocks of color on each layer when your done, fine tweaking the movement of scrolling and timings will make perfect. Good luck.

    If not, try adding an animation on board, you can create a Web page in Adobe Edge, but again... probably much more involved learning with this option.

  • How to use the same point of view as read only in the ADF and editable

    Hello

    How to use the same point of view as read only in the ADF and editable? How can we succeed in TF?

    -James

    Hello

    Steven Davelaar wrote a presentation on this 'building highly reusable Taskflows.

    From slide 14, that's where your use case comes into play

    Frank

  • How to display the database column value in a component of choice selected?

    Hello everyone;

    I use Jdeveloper 11.1.1.4 and right now I have the .jspx UI page that includes < af:selectonechoice / > components and according to the requirment I have to fill one of the column in the table in this drop-down list.

    can someone tell me how to fill the database column value in this drop-down list. I know I need to create the VO for the same thing, but I'm new to this technology. Then please suggest.

    Thanks in advance.,

    This will help u

    https://blogs.Oracle.com/prajkumar/entry/create_lov_in_adf_application

    How to create LOV in ADF 11 g | Techartifact

    Oracle Fusion Middleware Technologies: 11G: how to create a list of Values (LOV)?

    http://www.baigzeeshan.com/2010/03/creating-lov-in-ADF-application.html

    http://husaindalal.blogspot.de/2010/05/How-to-default-lov-with-its-first-value.html

Maybe you are looking for

  • Firefox takes back me to a microsoft technology if a problem is detected

    I tried to look at a link on facebook and she appeared that Firefox has detected 2 virus and said I should call to help solve the problem. The number gave me is 866-415-5853. I called and had a Global Access, who wanted to distance from my pc through

  • malicious program or a 10.9.5 OSX system library folder?

    There is Adware on a 2009 27 "iMac still under OSX 10.9.5 (for the 3rd party compatibility for example Adobe CS6 software suite). I followed the threads re. removal (thanks Linc Davis) and the problem does not come back. To the date of departure of t

  • Satellite 1400-503: what kind of RAM should I use?

    It is pre-installed with 256 MB of RAM (I think) and I would like to enhance it with additional 256 MB in the free location. What kind of RAM I need? the preinstalled is a samsung with the inscriptions on it: Korea 0228 pc133s-333-542-81 L7A M4645325

  • Open VB6 dll on labview COM type libraries

    Hi all I have a third party DLL generated from VB6 and I try to access its functions using the block "call library function. When I select the library path, I do not see the function I want on the field 'Function name' but if I type the name of the f

  • Error in the printer - Deskjet 6840

    My printer displays the message - "Not compatible with the printer ink cartridge" and will not print a document. I use HP 94 and 95 cartridges. They were new a month ago. The printer has been my reliable MAC since the purchase of this issue four or f