Subtract a rank on the other previous lines

If I have a data like this

ID Num1 Num2 result
110100100 10
220100100-20-10
33010030 / 20/100-10
440100100-40-30-20-10
550100100-50-40-30-20-10

How can I get the result as above with a SQL column

Hello

1004276 wrote:

If I have a data like this

ID NUM1 NUM2 Result
1 10 100 100 10
2 20 100 100-20-10
3 30 100 30 / 20/100-10
4 40 100 100-40-30-20-10
5 50 100 100-50-40-30-20-10

How can I get the result as above with a SQL column

It depends on what you mean.

Is

100-20-10

a string of 9-chararacter, or is it a number

If it is a NUMBER, it is 70 (i.e. (100-20) - 10, as Oracle would calculate it), or is it 90 (i.e., 100-(20-10))?

Maybe you want to the analytical SUM function, like this:

SELECT x *- or whatever the desired columns

, num2 - SUM (num1) over (ORDER BY id) SUITE

FROM table_x

ORDER BY id

;

Tags: Database

Similar Questions

  • How to draw a line (with the line segment tool) then draw another line, from those previous anchor point. When I try immediately draw another line on the other anchor lines it try to turn instead.

    I'm following a course of basic fundamental illustrator on Lynda. The video of "draw straight lines" is troubling me. They draw a line with the line segment and then draw another line coming out the anchor point at an angle.

    Here's where it is troubling me - when I try to drag a line to the anchor point trying to transform the first line, I drew. (the line cursor turns into a selection tool) I can't draw another line connecting the first.

    Advice would be great because it's driving crazy me.

    See you soon,.
    Kyle

    Yes, it is irritating. You must clear the previous line first. If you want to make sure that both ends are perfectly aligned, start by turning on the guides. If you want two lines to be part of the same way, you should use the tool pen instead.

  • Charge validation levels rank on the other lines?

    Hi all

    I use:
    The Version of database: Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - 64bi
    Database version: PL/SQL Release 10.2.0.5.0 - Production

    I'm trying to understand the best way to validate some dates placed in an array:
    create table foo (id number
                     ,start_date date
                     ,end_date date);
                     
    insert into foo (1111,to_date('01-01-2011','dd-mm-yyyy'),to_date('31-01-2011','dd-mm-yyyy'));
    
    commit;
    
    insert into foo (1111,to_date('01-02-2011','dd-mm-yyyy'),to_date('28-02-2011','dd-mm-yyyy'));
    
    commit;
    These two inserts are fine, but my business rules specifies that for each ID, I can't allow an insert with dates that overlap all other records for this ID.

    For example, this:
    insert into foo (1111,to_date('15-02-2011','dd-mm-yyyy'),to_date('31-03-2011','dd-mm-yyyy'));
    
    commit;
    Breaks down when inserting.

    Now, for the moment, we have a trigger that queries the other records in this table, but this causes an error table mutation. We define an autonomous operation but this obviously causes problems if you're updating multiple records at the same time.

    What is the best way to apply validation like this when inserting outside ensure that each entry point applies this business rule?

    Hi samir,.

    Here are two blogposts of mine on this topic that you might find useful.

    With some information on the modalities of entity: http://rwijk.blogspot.com/2008/08/implementing-entity-rules.html
    And the other with an example how to implement (among others) an overlap check as part of another option for your question, the product RuleGen: http://rwijk.blogspot.com/2008/05/rulegen-test.html

    I hope this helps.

    Kind regards
    Rob.

  • How to subtract one signal on the other, with the help of an oscilloscope?

    I have two chaotic oscillators, which I am trying to sync. There is an oscilloscope, which channels are related to each oscillator. I need remove the signal from the oscillator-B, the oscillator signal - A, using the oscilloscope, so that I can find how much is the error between them. A - B would work very well, but there is only A + b. is it possible to do, without having to add additional circuit elements? If this isn't the case, that I would add, subtract one signal from another?

    Edit: I use the classic Multisim 13.0 oscilloscope.

    Hello.

    You can invert the signal B-

    the standard scope 2 ch a reversal for Channel B - there are 4 small buttons on the bottom of the chB instead of only 3 for chA.

    Best regards

    Michael

  • Pass reference in table 2D with several lines-> Subvi - sees only 1 rank of the number of lines

    What I am doing wrong?

    Of course it is. The Value property. That feed into the size of the array. The output of the size of the table is a table - one element for each dimension of your table.

  • 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

  • With the help of the previous line in a formula calculator

    Hello.  I use the calculator to create a new string that is a custom filtered version of an existing channel.  Unfortunately, I was not able to identify the entrance of previous line in the channel.  To make things easier, let's say my filter is a simple averager.  This is simple pseudocode for what I want to do:

    New_Channel = (Existing_Channel [n] + Existing_Channel [n-1]) / 2

    where n is the current line.

    It's the calculator formula, with I came:

    ch("[1]/New_Channel") = (CHD (' chnRow - 1 ' [1] / Existing_Channel "") + ch("[1]/Existing_Channel")) / 2 + CTNV (chnRow > 1)

    Unfortunately, I think that chnRow returns 0.

    Of course, I'm a beginner.  I'm open to other approaches to the creation of a new channel with a custom filter.

    Thank you!

    Hi jbuttron,

    What you need to do is to copy the channel and remove the first value of the copied channel then the nth line of the original channel is aligned on the e line (N-1) of the copied string.  You must also add the last value of the string copied at the end of this channel as a new value that both channels end up with the same channel width.  Now you can reference the channels with Ch("[1]/old") and Ch("[1]/new") in the expression of canal's calculator, assuming that the channel names are 'old' and 'new' respectively and both are in the first group.  You need not row variable in the expression now, which is good because there is no way to iterate through a variable row in an expression of canal's calculator.  The iteration of the row is implicit in the reference channel Ch("[1]/new").

    Brad Turpin

    Tiara Product Support Engineer

    National Instruments

  • NB100: Line-In/Mic-In - how to pass from one to the other?

    Hi everyone - lists of specifications more list entry on the NB100 as an audio Mic-In/Line-In, but I can't find an option to go to the line.
    I would like to be able to record audio with an external preamplifier, therefore the Line-In input, would be really useful.

    Is it just the input that is activated when enabling/disabling gain/sensitivity between Mic-In/Line-In?

    The Mic-In volume would be the same as the change of Line-In?

    Any ideas?

    Thanks in advance :)

    Hello

    In your case you should take a look in the user manual.
    The user manual says that this laptop supports and taken headphone and Microphone jack.

    The mic jack is a standard 3.5 mm jack, and it allows the connection of a microphone or the other device to an audio input.
    This means that you do not need to change anything. Simply plug the connector of right to take.

    Good bye

  • Store the new values in the table in the new row so that the 'old' remains in the previous lines

    Hello

    I am a student of genius embedded. I did a VI where I change the values of digital controls, and it saves it as a table.
    I want to store the pair of new values in the new row of this table.
    I have attached a VI where I can change the values of numeric control, as well as the number of lines from another control. But when I change the values, all values in the output table change including values in the previous row. I want these lines to be unchanged and that new line to update.

    Need help.

    If I understand correctly, you want to always 4 models. If so a 2D table will do the trick (see annex VI), otherwise crossrulz' solution should work.

  • MAC address: Is it possible to change the MAC address of a machine & also if there is a way to see the physical address of the machine on the other to see through the command line...?

    Is it possible to change the MAC address of a machine & also if there is a way to see the physical address of the machine on the other to see through the command line...?

    Is it possible to change the MAC address of a machine & also if there is a way to see the physical address of the machine on the other to see through the command line...?

    Yes.

    Yes.

    Of course - you use 'other/unknown', then...?

    (Google for "MAC spoofing").

  • printer prints 4 lines on the other at the top of each printed page HP 6500 has more

    HP 6500 a Plus

    Print the top four lines of each page printed on the other

    Hello chris1015and welcome to the Forums of HP, I hope you enjoy your experience!

    I see that you have print quality issues.  I'd love to try to help you, but I need some information first. I'm a link a few HP Support documents below that will show you how to find what operating system you are using. In addition, if you are using Windows, please indicate if your operating system is 32-bit or 64-bit. With this information we can provide you with accurate information.

    Mac OS X: how to find which Mac OS X Version is on my computer?
    Operating system Windows am I running?
    Is the Version of Windows on my computer 32-bit or 64-bit?

    In addition, this problem occur when copying?

    Please let me know whqt you find, thank you for contacting the HP Forums!

  • Unable to speak using the 'phone dialer', hear the ringing tone. can hear the person on the other side... but he can't hear me... and when I press talk the line disconnects... I have an internal modem Agere on laptop HP Pavilion DV6-TX1152... pls help

    I'm develpoing apps using the SAPI, TAPI, however, I'm stuck with a fundamental question... when I dial a number, I can hear the ringtone on the speakers of the laptop... and I can hear the person on the other side as well... but he can't hear me... and as soon as the others left up to the 'Phone dialer' pcks pops up a window with two buttons... 'Talk' and 'Hang up', when I press the talk button, the line is automatically disconnected. Pleas help to solve this problem...

    Hi abhi.jeet,

    Thank you for visiting the website of Microsoft Windows Vista Community.

    The question you have posted is related to application development and would be better suited to the MSDN Community. Please visit the link below to find a community that will provide the support you want.

    http://msdn.Microsoft.com/en-us/default.aspx

    Hope this information is useful.

    Jeremy K

    Microsoft Answers Support Engineer
    Visit our Microsoft answers feedback Forum and let us know what you think.

  • When the typing cursor moves by itself to a previous line

    As I type the cursor moves by itself a previous line, and the text is all mixed up. Say, you typed a few lines, the cursor will then move WARNING witout a previous word or line, and the text becomes involved. (until typing this I've had to delete garbled text 4 times and re type)
    I've upgraded to Windows 7 Home Premium to Vista using the Acer upgrade kit no problems before the upgrade.
    Acer Aspire 5738Z
    Pentium T4200 processor
    4 GB of Ram
    320 GB HD

    How your problem is related to Windows Update (compared to the Windows upgrade)?

    You may have to contact the Acer Support?

  • How can I get lines to work alongside the other instead of below each other

    Hi, I am a complete novice with limited technical capacity and try to learn the bootstrap, I want a provision which consists of a large image or movie to the left of the page and a few rows of images in front of the right. Is it possible to put the lines next to each other instead of below the other? I have sort of this successful using the tag ASIDE on a line, but am unsure if this will cause problems when the site is published. Also is it possible to place an image or a text on the greyed out the column when he has been compensated? Any help would be received with gratitude by the beginner difficulty

    If you are a perfect beginner with limited technical capacity, Bootstrap is not a good place to start. To work properly with Bootstrap, you need a pretty good knowledge of HTML and CSS.

    That said, to answer your questions:

    • No, you cannot "bootstrap" rows side by side. The question of a line, it's that it spans the entire width of its container. However, you can nest rows within a column. You can do one of the reasons are a top element on one side of the page with two or more lines of smaller elements on the right.
    • No, you can't put anything into space alongside a column that was offset. The idea of compensation is to leave space on the left flank.

    If you have a subscription to lynda.com, you can learn much more about the use of bootstrap in Dreamweaver CM³. I have published a course called Responsive Design with Bootstrap and Dreamweaver CC 2015. It is not free, but you can get a free 10-day trial (free trial version does not include the sample files).

  • missing parenthesis in insertion into separate lines select the table from the other table

    Hello

    could you help me with the following question?

    I have the following tables

    CREATE TABLE table1)

    ID varchar (12),

    col2 varchar (10),

    COL3 varchar (10),

    level varchar (10))

    CREATE TABLE table2)

    Id2 varchar (12)

    A varchar (10),

    B number (1)

    CONSTRAINT PRIMARY KEY PK (ID2, is));

    INSERT INTO table2 (ID2, A, B) SELECT ID, col2

    MAX (CASE WHEN level = "level 1" then 1

    level = 'level 2' then 2

    Level = 3 then 'niveau3') as colIN3)

    FROM table1 GROUP BY ID2, a.;

    the first table have duplicates as follows:

    Id2 COL2 COL3 level

    A1 pepe football level1

    A1 pepe football level2

    A1 pepe football level1

    A1 pepe basket level2

    A1 pepe pingpong level3

    the output should be selected with unique key (ID2, col3) lines and the level must be the greatest.

    Id2 COL2 COL3 level

    A1 pepe football level2

    A1 pepe basket level2

    A1 pepe pingpong level3

    The output of the script tells me the following messages:

    -lack of right parenthesis referring to the max function.

    Thanks adavance.

    Kind regards

    Hello

    Remember the ABC's of the GROUP BY:

    When you use a GROUP BY clause or in an aggregate function, then all in the SELECT clause must be:

    (A) a ggregate function,

    (B) one of the expressions "group By."

    (C) adding to C, or

    (D) something that Depends on the foregoing.  (For example, if you "GROUP BY TRUNC (dt)", you can SELECT "TO_CHAR (TRUNC (dt), 'Mon - DD')").

    To ask him, there are 5 columns in the SELECT clause.  The last one is a function MAX (...); It is an aggregate, is not serious.

    The first 2 columns are also named in the GROUP BY clause, so that they are well.

    The other 2 columns, country and internal_Id do not match any of the above categories.  These 2 columns cause the error.

    There are many ways to avoid this error, each producing different results.  You could

    • remove these 2 columns in the SELECT clause
    • Add these 2 columns in the GROUP BY clause
    • use the aggregation such as MIN, 2-column functions
    • remove the country from the SELECT clause and add internal_id to the GROUP BY clause
    • remove the internal_id from the SELECT clause, and add countries to the GROUP BY clause
    • ...

    What are the results you want?

    Whenever you have a question, please post a small example of data (CREATE TABLE and INSERT statements) for all the tables involved, so people who want to help you can recreate the problem and test their ideas.  Also post the results you want from this data, as well as an explanation of how you get these results from these data.

    Always say what version of Oracle you are using (for example, 11.2.0.2.0).

    See the FAQ forum: https://forums.oracle.com/message/9362002

Maybe you are looking for

  • Hello my name is Tatiana

    I try to activate my Apple account with my samsung laptop please help

  • Paviilion-15-g019wm demoted to Win7-64-need drivers!

    Paviilion-15-g019wm (p/n F9H60UA) w/1.0 GHz AMD E1-2100.  Downgraded to Win7-64, need of controller SM Bus and USB controller drivers.  HP support and the software online without help here!  HP support is no help here at all. Will not be same id chip

  • portable devices

    play for sure

  • Problems type withWindow Vista Home Premium

    Well Mr President... I did visit my mother yesterday and had a computer sitting next to her door, if it was a nearby computer and it ask me to look at him because he thought he had a virus.  It's a Hp Pavilion with a processor AMD Phenom x 4... model

  • Error code 0 x 80070057 - refuses to do a system repair disc

    There it is again! I tried to do a system repair disc on my hp ProBook laptop computer brand new with Windows 7. I have inserted a DVD r and hit all the right buttons but got the message "system repair disc could not be created: parameters are incorr