Problem I have TO solve with the query: PREV calculation to the current record

Hi all

My version of db:

Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

I have the problem to solve with a request (MUST BE a SELECT statement), but I do not understand how... I tried with the analytical function but... not just:

I have this table:

rownumKEY1KEY2A3PERCIMP
1A123RISCP01/01/201410100
2A123RISCP02/01/201411100
3A123RISCP03/01/201415100

Application of expected result:

RESULTSKEY1KEY2A3PERCIMP
90A123RISCP01/01/201410100
80.1A123RISCP02/01/201411100
68.085A123RISCP03/01/201415100

Starts recording with rownum 1 (the lower date with the same KEY) I do: imp - (100 imp * perc), where imp = 100 and PERC = 10, so the first result of the calculation is: 90


Now I have to go to record 2, so I do 90 - 11%: imp - (100 imp * perc), where imp = 90 and PERC = 11, results is 80.1

Now I have to go to the 3d recording, so I 80.1 - 15%: imp - (100 imp * perc), where imp = 80.1 and perc = 15, results is 68 085

So I have to use the previous to the current PERC.

I'm sure it's possible through a combination of funcion analytical!

Thanks to anyone who can help me!

with

data in the form of

(select 1 rn "A123" key1, to_date('01-JAN-2014','DD-MON-YYYY') dat, 10 perc, 100 imp union double all the)

Select option 2, 'A123', to_date (February 1, 2014 "," MON-DD-YYYY ""), 11, 100 of all the double union

Select 3, 'A123', to_date (March 1, 2014 "," MON-DD-YYYY ""), 15, 100 double

),

Solver (RN, Key1, DAT, PERC, IMP, result) as

(select rn, key1, dat, perc, imp, imp * (1 - 0.01 * perc))

from the data

where rn = 1

Union of all the

Select d.rn, d.key1, d.dat, d.perc, d.imp, s.result * (1 - 0.01 * d.perc)

s Solver,

data d

where d.rn = s.rn + 1

)

Select *.

the Solver

RN KEY1 DAT PERC IMP RESULT
1 A123 01/01/2014 10 100 90
2 A123 01/02/2014 11 100 80.1
3 A123 01/03/2014 15 100 68.085

Concerning

Etbin

Tags: Database

Similar Questions

  • I'm looking to move from Windows/Apple/logic and Cubase Cubase. My questions have to do with the current (2014) Mac mini, specifically the i5 $999 2.8 GHz with 8 GB of RAM. This computer will be powerful enough to run the current logic without any pr

    I'm looking to move from Windows/Apple/Logic Pro X and Cubase Cubase.

    My questions have to do with the current (2014) Mac mini, specifically the i5 $999 2.8 GHz with 8 GB of RAM.

    This computer will be powerful enough to run Logic Pro X DAW and Cubase 8 courses without any problem?

    I would say yes, but I post here too:

    Logic Pro

  • Developer Mode error: outdated., the xxAM.xxVO1 view object contained no trace. The records displayed may have been deleted, or the current record of the view object is not properly initialized.

    Hi all

    I'm creating a Maunal search page.

    To do this, I created a view based on a custom display object.

    Page contains 2 parameters.

    If I give all settings and click the OK button.

    It gives the following error.

    Developer Mode error: outdated data


    This page contains outdated information. This error could have been caused by the use of the buttons of the browser (the browser back button, for example). If the browser navigation buttons were not used, this error may result from coding errors in the application code. Please check press the back button on the browser developer guide - view primary key object comparison section to review the main cause of this error and correct the mistakes of coding.


    Cause:
    The view BLTrinDisplayAM.ViewVO1 object did not contain any record. The records displayed may have been deleted, or the current record of the view object is not properly initialized.

    To visit, please click on the Home link at the top of the application page to return to the main menu. Next, go to this page using the app's navigation controls (menu, links and so on) rather than use the controls of the browser as rear or front.

    If I don't give any parameter and click go Button.The content of the view are displayed.

    So if I pass all parameters and click Go, then the corresponding record is displayed.

    Why, for the first time, if I give the parameter and click Go, obsolete data error is coming?

    Please help me.

    Grateful for your help!

    -Aren

    You use the object of the view for the search criteria and search results fields.

    I suggest you to remove references of VO fields of search criteria, item1 and item2.

    And in the event of the button 'Go' in the processFormRequest, get the criteria for field values entered by the user as below and run the object (ViewVO1) of the view by using these values.

    String buCode = pageContext.getParameter ("item1");

    String lsiCode = pageContext.getParameter ("item2");

    Thank you

  • need to recover the previous registration with the current record

    Hi all

    I have a table like,
    ID, name, date_de_modification, prev_loc

    1, 'ABC', March 23, 2009, "A1".
    2, "XYZ", March 23, 2009, "C1".
    3, "KLM", March 23, 2009, "C1".
    4, '012', March 23, 2009, "C1".
    5, '1231', March 23, 2009, "C1".
    6, "XYZ", March 23, 2009, "C1".
    7, '435', March 23, 2009, "C1".
    8, "homeless", March 28, 2009, "C1".
    9, 'Bad', March 27, 2009, "C1".
    10, 'ABC', March 29, 2009, "B1".
    11, "345df", March 29, 2009, "C1".
    12, 'ABC', March 29, 2009, "C1".

    Requirement:
    for 'ABC', there is 3 files. at the top is id 12. with this record I want view prev 'ABC' with id 10 folder, then
    record with id 10 I want to display folder prev 'ABC' with the id 1 as wise...

    I want o/p as:

    12, 'ABC', MARCH 29, 2009, C1, B1
    10, 'ABC', MARCH 29, 2009, B1, A1
    1, 'ABC', March 29, 2009, A1, null

    Kind regards
    Krishna Prasad

    Published by: user9933144 on April 29, 2009 02:11

    Hello, something like:

    WITH tab AS (
    SELECT 1 ID, 'ABC' name , TO_DATE('23-March-2009', 'DD-MON-YYYY') date_modified, 'A1' prev_loc FROM DUAL UNION ALL
    SELECT 2, 'XYZ' , TO_DATE('23-March-2009', 'DD-MON-YYYY'), 'C1' FROM DUAL UNION ALL
    SELECT 3, 'KLM' , TO_DATE('23-March-2009', 'DD-MON-YYYY'), 'C1' FROM DUAL UNION ALL
    SELECT 4, '012' , TO_DATE('23-March-2009', 'DD-MON-YYYY'), 'C1' FROM DUAL UNION ALL
    SELECT 5, '1231' , TO_DATE('23-March-2009', 'DD-MON-YYYY'), 'C1' FROM DUAL UNION ALL
    SELECT 6, 'XYZ' , TO_DATE('23-March-2009', 'DD-MON-YYYY'), 'C1' FROM DUAL UNION ALL
    SELECT 7, '435' , TO_DATE('23-March-2009', 'DD-MON-YYYY'), 'C1' FROM DUAL UNION ALL
    SELECT 8, 'sdf' , TO_DATE('28-March-2009', 'DD-MON-YYYY'), 'C1' FROM DUAL UNION ALL
    SELECT 9, 'gdfg' , TO_DATE('27-March-2009', 'DD-MON-YYYY'), 'C1' FROM DUAL UNION ALL
    SELECT 10, 'ABC' , TO_DATE('29-March-2009', 'DD-MON-YYYY'), 'B1' FROM DUAL UNION ALL
    SELECT 11, '345df',TO_DATE('29-March-2009', 'DD-MON-YYYY'), 'C1' FROM DUAL UNION ALL
    SELECT 12, 'ABC' , TO_DATE('29-March-2009', 'DD-MON-YYYY'), 'C1' FROM DUAL)
    -- End of test data
    SELECT Id, name, date_modified, prev_loc,
              LAG(prev_loc) OVER (PARTITION BY name ORDER BY id) prev_prev_loc
     FROM tab;
    
             ID NAME  DATE_MODI PR PR
    --------- ----- --------- -- --
             4 012   23-MAR-09 C1
             5 1231  23-MAR-09 C1
            11 345df 29-MAR-09 C1
             7 435   23-MAR-09 C1
             1 ABC   23-MAR-09 A1
            10 ABC   29-MAR-09 B1 A1
            12 ABC   29-MAR-09 C1 B1
             3 KLM   23-MAR-09 C1
             2 XYZ   23-MAR-09 C1
             6 XYZ   23-MAR-09 C1 C1
             9 gdfg  27-MAR-09 C1
             8 sdf   28-MAR-09 C1
    

    Published by: Seanmacgc on April 29, 2009 02:36

  • The only problem I have now is with the video game streaming. In my view, FF 9 was released. I'll wait to read comments before the upgrade as I am leary to make things worse.

    I have no other details.

    It's really hard to say what could be the problem. It may even be something as a change to your internet connection quality (not something done by you). 9 FX is available if you want to try it - mozilla.org/firefox

  • Unexpected behavior with the Option "record in the result.

    Hello

    I have unexpected behavior with the Option "record in the result.

    I have a few steps in the subsequence 'X', this subsequence passes a Boolean parameter. According to the value of the parameter I change the "Recorgind results" Option to report it or not. The thing is that if 'result Recorgind' set at race time I modofy by changing the value of Step.ResultRecordingOption to "Enable" and "Disable", the step is not reported until the same sous-suite 'X' is called for the second time (without changing the parameter passed).

    For example: (Preconditon: result Recorgind Option of all value sous-suite x are defined as Disable)

    1 CallSubsequenceX(Parameter: Enable)

    2 CallSubsequenceX(Parameter: Enable)

    3 CallSubsequenceX(Parameter: Disable)

    4 CallSubsequenceX(Parameter: Disable)

    Expected result:

    1. measures have been reported.

    2. measures have been reported.

    3. measures have not been reported.

    4. measures have not been reported.

    Result:

    1. measures would not same value Step.ResultRecordingOption has been changed to 'enable '. (Not Ok)

    2. measures have been reported. (Ok)

    3. measures reported same value Step.ResultRecordingOption has been changed to 'disable '. (Not Ok)

    4. measures have not been reported. (Ok)

    I use TestStand 2013 (5.1.0.226)

    Thanks in advance.

    -Josymar.

    Hi josymar_guzman,

    I just review the sequence and indeed we´re experience unexpected behavior with the Step.ResultRecordingOption callback. By a reason when you run the callback in the expression before each step section, the statement runs only until the next sequence is called, which is not what we want.

    To avoid this, you can place a statement before each step of the sequence, so you can change the State of the Option "record result" for the sequence running (and it is only the following). You can try something like this

    where the expression of the statement will be the recall "RunState.NextStep.ResultRecordingOption is YourCondition". With this, we guarantee that the results of the next step will be saved or not. I also remove the expression in the expression prior to each step section, because the condition is now on the statement before each step.

    I tried and it works fine. I´ll set the sequence that you share with me, with the changes. I hope this will help you and solve your problem.

  • Since 10.11 I have not been able to download via the usb port of my Davis Vantage weather station. No solution of tech Davis on the issue even with the new recorder of events in the resort. Is there a problem with the usb?

    Since 10.11 I have not been able to download via the usb port of my Davis Vantage weather station. No solution of tech Davis on the issue even with the new recorder of events in the resort. Is there a problem with the usb?

    What Mac? (details)

  • Hello. I have a big problem. I have Photoshop, Indesign, Illustrator CS4 and Flash CS5 programs. I bought the programs a few years ago and used on my Mac with version 10.6.8. Now, I have a MacBook with the latest version 10.11. I wanted to copy the pro

    Hello. I have a big problem. I have Photoshop, Indesign, Illustrator CS4 and Flash CS5 programs. I bought the programs a few years ago and used on my Mac with version 10.6.8. Now, I have a MacBook with the latest version 10.11. I wanted to copy the programs on my MacBook to work also on this computer. I copied the folder with the programs 'Programs' and the folder of the "Library / Application Support / Adobe" on my USB key and pulled on the MacBook in the program folder and the folder of Adobe. Then I restarted the computer. When I wanted to start a program, I got with Photoshop, Illustrator, and Flash, the error 6 error message. For Indesign: "Adobe ID missing required files please reinstall missing file / Library / Application Support / Adobe / support /... / ROMAN." TXT ".» But on my old computer I could not find a record of support for the Type in the path to the Library / Application Support / Adobe. And I don't know what I have to do because of error 6. Can someone help me please? Thank you very much.

    Avoid copying files from one computer to the other. It won't work. You run out of hidden files scattered around the hard drive and interrupt the licensing mechanism.

    Uninstall, run the cleanup tool.

    Adobe - Adobe CS5 clean tool

    Reinstall from scratch and enter your serial number.

    Download download install and Installation Help | Download and Installation Help

    They will install under 30 days of testing. Enter your valid serial number to unlock the tests.

  • Network problem between Windows 7 laptop with the Windows XP desktop computer via Linksys WRT54 router.

    Original title: network problem!

    How can I get my laptop with Windows 7 Home Edition to connect to my desktop with Windows XP on it. I have a router Linksys WRT54 plugged directly to the desktop via ethernet and my laptop has an excellent signal but I can't access programs or the printer with it. I know the 'host group' on 7 but XP isn't that. Are there alternative than to put 7 on my desktop? Any suggestions?

    Thank you!

    Hello

    Thanks for posting your query in Microsoft Community and we give the opportunity to help you.

    According the description of the problem face you connection problems in Windows 7 laptop with the Windows XP desktop computer via Linksys WRT54 router.

    Residential group option is available on Windows 7 and Windows 8 operating systems. However, you can see the following article for more information on the connection of Windows 7 and Windows XP computers:

    Networking of computers running different versions of Windows

    http://Windows.Microsoft.com/en-in/Windows7/networking-home-computers-running-different-versions-of-Windows

    Hope this information helps. For any other corresponding Windows help, do not hesitate to contact us and we will be happy to help you.

  • Can I have several structures with the same case of event event?

    Hello

    I do an application which reproduces the front of the power supply HP6675A. To do this, I did a machine to States with different States

    (initialize, measures, voltage, current, ocp, ov, store, recall, etc.). In each State, should have a structure of the event that attracts the events of the buttons, as for example: If the current state is the voltage mode and the current button is pressed the next State will be the current mode. For this purpose in each State of the state machine should be the same structure of event with the same events.

    My problem is that the Vi does not work properly when I have several structures with the same case of event event. There are some possibly to do and how? Or is impossible to have several events? I read a few posts, but I can't find solutions.

    Any help is appreciated.

    Thank you very much.

    In general, you should have 1 structure of the event in your VI.  In your state machine, the structure of the event should be in "pending" status  So you will probably start in the State of the initialization and then spend idling.  Then, the user presses the present button.  If your state machine should then, go to the current state and then return to Idle.

  • Have XP Pro with the Panel open, click on add/remove progs - nothing happens. All the other c/Panel open Fredrick help OK

    Have XP Pro with the Panel open, click on add/remove progs - nothing happens. All the other c/Panel open Fredrick help OK

    Hey Fredrick,

    ·         You get the error message?

    ·         Did you do changes on the computer before the show?

    Follow these methods.

    Method 1: Run the following command:

    Start, run, Appwiz.cpl

    Check if you can run the Add / Remove programs.

    Method 2: Scan the file system (CFS) auditor to repair corrupted files.

    Description of Windows XP and Windows Server 2003 System File Checker (Sfc.exe)

    http://support.Microsoft.com/kb/310747

    Method 3: Follow these steps:

    Step 1: Start the computer in safe mode and check if the problem persists.

    A description of the options to start in Windows XP Mode

    http://support.Microsoft.com/kb/315222

    Step 2: If the problem does not still in safe mode, perform a clean boot to see if there is no conflict of software like clean boot helps you eliminate software conflicts.

    How to configure Windows XP to start in a "clean boot" State

    http://support.Microsoft.com/kb/310353

    Note: After completing the steps in the clean boot troubleshooting, follow the section How to configure Windows to use a Normal startup state of the link to return the computer to a Normal startupmode.

    After the clean boot used to resolve the problem, you can follow these steps to configure Windows XP to start normally.

    (a) click Start, run.

    (b) type msconfigand click OK.

    (c) the System Configuration Utility dialog box appears.

    (d) click the general tab, click Normal startup - load all services and device drivers and then click OK.

    (e) when you are prompted, click on restart to restart the computer.

    Method 4: Performs a search using the Microsoft safety scanner.

    http://www.Microsoft.com/security/scanner/en-us/default.aspx

  • I have 109 IRQ with the compliant ACPI Microsoft-system description

    Original title - IRQ

    I have 109 IRQ with the compatible ACPI Microsoft-system description. IS this normal or am I safe to remove/disable all but 1?

    I think this may be the cause or caused by my system freezing and the origin of my screen to go black and the only cure is to set or turn off the system.

    Any help or thoughts would be greatly appreciated

    Thank you

    Brian

    Hello

    Thanks for the reply.

    If you are able to get to the screen, then you can perform

    You can check the disk for errors and repair problems related to bad sectors, lost clusters, reticulate files and directory errors.

    Check a drive for errors: http://windows.microsoft.com/en-us/windows7/Check-a-drive-for-errors

    Important: while performing the check disk on the hard disk, if bad sectors can be found, then check disk will try to repair this sector. All the data available in this area may be lost.

    In addition, you can also scan the computer using Windows Defender in offline mode.

    Windows Defender offline because it can help eliminate hard to find malicious and potentially unwanted programs using definitions that recognize the threats. The virus scan done offline using Windows Defender is different because the scan is done outside of the Windows environment.

    Definitions are files that provide an encyclopedia of potential software threats. Armed with definition files, Windows Defender in offline mode can detect malicious and potentially unwanted software and then inform you of the risks.

    What is Windows Defender Offline?: http://windows.microsoft.com/en-US/windows/what-is-windows-defender-offline

    Note: There could be a loss of data while performing a mode offline scan using Windows Defender to remove viruses as appropriate.

    Response with the State of the question and we will be happy to offer you our help.

  • page every time I try to download a free trial version for the sequels, I get to the legacy that when I click on free trial he always says we know the atm problem but its nothing to with the wifi is good, but its unique every time Please HELP

    page every time I try to download a free trial version for the sequels, I get to the legacy that when I click on free trial he always says we know the atm problem but its nothing to with the wifi is good, but its unique every time Please HELP

    You MUST have a 64-bit computer and operating system... What is your computer?

    -Programs are supposed TO not view or download if they are not installed on your computer

    MINIMUM for After Effects and Premiere Pro http://helpx.adobe.com/premiere-pro/system-requirements.html

  • I used to have a box with the letters/folder called "All messages" - I do not have. Don't know what happened to her - I guess I could have deleted by accident? Can someone tell me how to get it back? Thank you

    I use the MAIL function on my MacBook Pro. I used to have a box with the letters/folder called "All messages" - I do not have. Don't know what happened to her - I guess I could have deleted by accident? Can someone tell me how to get it back? Thank you

    What do you mean 'all messages '? all mail entering, or email any or all all. ?

  • I have 2 bookmarks with the same name but different stuff in them. I want to remove one, but pass the contemts remaining bookmark

    I have 2 bookmarks with the same name but different stuff in them. I want to remove one, but pass the contemts remaining bookmark

    This is the first mention you made records. See this - https://support.mozilla.org/en-US/kb/Sorting%20bookmarks#w_rearranging-manually - and move individual bookmarks from one folder to the other folder. You may need to press the Alt key to display the Menu bar and the View menu item.

Maybe you are looking for

  • -Updated windows 8.1 - information page - IMPORTANT! -- --

    For those who updated the system to win 8 to 8.1 Win. I found very interesting and useful information on the EU from Toshiba support page: I recommend this update for Toshiba to the information page for Windows 8.1:[Update of Windows 8.1 | http://www

  • Satellite A500 - display driver failed

    Hello Recently, my three year old Toshiba A500 (0400E PSAM3A) has started to display the message "Display Driver failed" and the screen became all BEHLULI and weird. I'm sure it's the graphics card, open the computer self and he cleaned it with an ai

  • new router, printer now Wireless does not work.

    We had trouble getting online.  ISP determined it was our router.  Bought and installed new router.  Internet access children laptops and thin, but now HP photosmart Plus B209 sees no new router.  Tried to Setup Wizard, no luck, tried to push button

  • HP photosmart c4700series printer driver so far

    I bought a new Dell all in one PC need to install my printer but tells me it doesn't have an update of the driver so that he ' d, help please

  • DV 1412 with Windows 7 (32 bit). Biometric

    I recently bought my Windows 7, 32-bit after installation and also using the driver cd, I still cannot recover a part of the drivers. The Digital Persona is completely installed and same work obtained new updates, the problem is that the drivers for