Calculate if got only positive and negative values

I have this problem that I need help.

I have this table called MESSAGES. There fields client_name and AMOUNT like this:

MESSAGES*.

CUSTOMER NAME_
Amy
Amy
Amy
Bill
Cheryl
Cheryl

AMOUNT
500
-200
-100
-111
50
100


As noted, my client AMY has 3 quantity: 500, -200, -100. I want my PL/SQL in order to calculate to summarize these amount if the amount of the same client_name 1 has a value negative and positive, and all remaining the same if all of its values is positive or negative.

Result:

CUSTOMER NAME_
Amy
Bill
Cheryl
Cheryl

AMOUNT
200
-111
50
100

How am I suppose to do?

Hey lee,

hope this helps

SQL> SQL> Create Table lee_test As  2  (  3  Select 'Amy' Name,   500    amt    From dual Union All  4  Select 'Amy'    ,    -200          From dual Union All  5  Select 'Amy'    ,    -100          From dual Union All  6  Select 'Bill'   ,    -111          From dual Union All  7  Select 'Cheryl' ,    50            From dual Union All  8  Select 'Cheryl' ,    100           From dual  9  );

Table created

SQL> SQL> Select Unique  2         Name,  3         Case When min_sign != max_sign Then Sum(amt) over (Partition By Name Order By Name)  4         Else amt  5         End amt  6  From  7  (Select Name,  8         amt,  9         min(sign(amt)) over (Partition By Name Order By Name) Min_sign, 10         Max(sign(amt)) over (Partition By Name Order By Name) max_sign 11  From lee_test 12  ) 13  Order By 1;

NAME          AMT------ ----------Amy           200Bill         -111Cheryl         50Cheryl        100

btw: are you chinese (cantonese??)

Tags: Database

Similar Questions

  • How can I design square wave which has a positive and negative values equal to the other and separated from each other by controlled time or distance

    How can I design square wave which has a positive and negative values equal to the other and separated from each other by controlled time or distance, as indicated in the figure below. and enter this signal in a data acquisition.

    At the time wherever you go for the beautiful diadram, you could have done the vi

    Your DAQ would like a waveform (table of values and dt ak 1/sampling rate)

    If you set the sampling rate you know the length of the array, create a matrix of zeros and set the values of the two amplitudes...

    Because I don't want to connect other duties here are some photos

    And it does have a few drawbacks leaves to be desired in my solution, just think... rounding errors and what might happen if the tables are becoming more...

  • SELECT statement: summing up a positive and negative value

    If I want to get the sum of the positive and negative values, can I do it like this?


    Negative:
    Select sum(amount) INTO negative_amt FROM order where amount like '%-%';
    Positive:
    Select sum(amount) INTO positive_amt FROM order where amount not like '%-%';
    If this is not the case, how should I go about this?
    SQL> SQL> With t As  2  (  3  Select   -100 c1 From dual Union All  4  Select -300    From dual Union All  5  Select -15.6    From dual Union All  6  Select 90    From dual Union All  7  Select 80    From dual Union All  8  Select 300    From dual Union All  9  Select -203.8    From dual Union All 10  Select 922.56    From dual 11  ) Select Sum(neg_num) neg_num, Sum(pos_num) pos_num 12    From 13    ( 14    Select Case When c1 < 0 Then c1 Else 0 End neg_num, 15           Case When c1 > 0 Then c1 Else 0 End pos_num 16    From t 17    ) 18  /
    
       NEG_NUM    POS_NUM---------- ----------    -619.4    1392.56
    
    SQL>
    
  • Positive and negative frequency of calculation deviation

    Hello

    IAM with PXI-5620 to measure RF PXI 5600.

    I need to measure the frequency deviation, Positive and negative. The example or vi "MT DAMA demodulate FM.vi" gives peak frequency deviation . Can any please help me find the positive frequency Deviation and negative frequency deviation of her

    Thank you

    Niju.

    Hi Johanna,.

    First things first - 5620 5600 + combined is what we call a PXI-5660 RF Signal Analyzer.

    The PXI-5660 module cannot be presence via the driver NOR-DAMA. The Modulation Toolkit FM sample that you reference is for the PXI-5661 and SMU-5663 analyzers, both use the driver NOR-DAMA.

    You use MT ni5660 FM demodulation. vi, located under the ni5660 examples.

    Now to your question...

    When you perform an FM demodulation, resulting the Subvi MT Demodulat FM data frequency / time with the frequency values (Y axis), is compared to the carrier frequency specified. Thus, data deviation of frequency (Hz), function of time. All you need to do to get the positive and negative frequency deviation is to use LabVIEW table Max & Min primitive functions of table palette. This will give you the min and max value of the FM data that will be the negative peak and the positive peak frequency deviation.

    Concerned,

    Andy Hinde

    RF systems engineer

    National Instruments

  • Guagewith scale positive and negative scale

    Hi all

    I thought it was simple. I need a gas reading of 0 to + or - 180 degrees either side of GUE positive readings figures up to 108 degrees, and the other side negative readings to-180 degrees

    Several skeins

    Greg

    1. use the text tool and enter the values on the ends of the scale.

    2 properties: scale. Enter the minimum and maximum values.

    3. other ways also exist, such as the nodes property.

    Lynn

  • SessionUtils.ExportSession - export only known and inferred values?

    Hello

    The SessionUtils.ExportSession method appears in support of two ways to export data from interview:

    (1) only known export, data provided by the user

    or (2) export data provided by the user, unknowns and deducted.

    Often, the amount of "unknown" data can be lengthy and is unknown, it generally does not provide a lot of value in a perspective of integration; pass data just unknown around in an XML object can be cumbersome.  And export only the data provided by the user is not particularly useful in integration scenarios where a value is updated based on the ability to infer the OPA.  Is there a way to export only the known (user-supplied) and inferred values, while ignoring the unknown?

    We currently take in charge "verbose" or not detailed in option for the ExportSession.

    If your concern is storage or transmission, maybe you could look at an intermediate step that eliminates the elements of undesriable.

  • positive and negative rotation numbers

    Hi all

    I create a roulette game that calculates the winning number based on the rotation of the main wheel. I'm if/else using statements to determine the winning number based on the rotation. I am tracking the rotation in the output panel. I want my rotation to go between 0 and 360, but the output panel trace 0-180, then it starts from "-180-0."

    The wheel can turn several times. No idea how to keep the positive numbers between 0 and 360, and do not have to write my if else to accommodate negative numbers?

    Thank you!

    var rot: Number = (whatever._rotation+360)%360;

  • angles, positive and negative area on a plot of polar

    Is there a way to label the sector on a polar plot angles with +/-values? We generate a lot of bosses of directivity of sonar and angles scored from-180 to 180 instead of 0 to 360 have long been the norm. Looking at the definition of the curve and Polar - display the tab - it doesn't seem to be an obvious way to do it.

    Hi Greg,.

    Unfortunately, there is no way to do in tiara at the moment. I presented a report of Corrective Action to resolve this (#323394), and I hope that this feature will be included in a future version of DIAdem. Thank you for that bring to our attention.

    Kind regards

    Jackie

  • Grid Y looking positive and negative in CS5

    I know there is another thread with discussion on why different programs the y axis upside-down, which is good.  The problem is that all the previous versions of Illustrator have your zero point as it would on a normal mathmatical grid.  Why now after 7 years of using Illustrator must I "Rethinking" how I move objects.  We create dielines and now if I put my text of the measure and captions on the top and bottom, to do the opposite of what we have done during all these years.  Besides the work placement.  Why is there not an option?  It's pathetic to from Adobe.  Someone please tell me there is an option to invert the y-axis now inverted.

    Monika said.

    Here it is:

    To change the origin of the rule in CS5 are the same as in CS4 and earlier versions, you can:

    (1) find and open the AIPrefs (Win talk) or Adobe Illustrator Prefs (Mac talk) of the file. It is a hidden file in the folder hidden settings of Adobe Illustrator CS5

    (2): find and replace the following two bits of code:

    /isRulerOriginTopLeft 1 > /isRulerOriginTopLeft 0 (replace the 1 with a 0)

    /isRulerIn4thQuad 1 > /isRulerIn4thQuad 0 (replace the 1 with a 0)

    Note: This is a global change.

  • remove the negative values in table

    I have a table 1 d of data depending on the positive and negative values. I'm trying to search for negative values and remove them from the table.  This corresponds to the data in the column in the second table 2D that should also be deleted. A minor problem is that there are an additional column in the 2D array that must be skipped.  I have the code that should do it.  The problem is that if I have two negative numbers in a row the code doesn't thow on the other.

    This first picture is the answer I get when alternate positive and negative values.  It shows the correct answer.

    When I change the first1 of the positive a-1 value as shown below...

    ... I get the following response.

    FYI, some other things such as conversion are here because I'm trying to manipulate the actual data set is enormous.  I test everything I do with the numbers that I can actually follow before I apply in my real program.  That's why I do extra things.

    Thanks for the help!

    Here is the solution, that increase the index when you do not remove an element. In addition, whether you use the "less then or equal" when you use the "lower to."

  • How can I do to two clips have the same position and scale?

    I just first Elements 10 today, since I'm doing a video for work. I am a seasoned videographer (I am a fairly successful YouTuber), but not with Adobe products. At home, I use Cyberlink PowerDirector 13 (although that is seriously considering moving to Premiere Pro), but for the moment at work I use elements since it is the program that they have.

    One thing that elements can do that PowerDirector is automatically align the clips at the same time. What I need to do, it's got a picture (do not fill the entire screen) suddenly cut to a similar picture of the same size and position, of the effect that the only part of the image changes. In my program to another, all I had to do was put them at the same time, change the shape of the Pic 1 how I want it, move the 2 Pic and do align on the same size and position, then move 2 peak after another in the timeline panel. However, items not the snap to each other, so I have no idea how to put them in the same size and position, one after the other.

    How can I do this? If this can be done in two elements or Pro, I'm going to have to Pro since I use this feature a lot.

    Thanks in advance!

    -Michael

    Michael

    First Elements 10 on what operating system? What video/graphics card your computer use? If NVIDIA GeForce, so we talk 10/NVIDIA GeForce display and other problems related specifically to first Elements.

    But, so far away that...

    Each clip on the Timeline of 10 elements first has a range of properties that contains a sign of movement. The expanded Motion Panel includes settings for the clip Position and scale. among other things.

    Position of two values... (___) (_) first from right to left and from left to right... second for up down or down the most.

    Have you been to the Palette of the 2nd clip properties to set its Position and scale values must match the first element?

    Have you been there and done that?

    Please read and review, and so let me know if I've targeted to what asked you. If this isn't the case, please specify where I missed what you were looking for.

    We'll rethink the situation if necessary and provide screenshots if necessary.

    Thank you.

    RTA

  • Tension running from negative to positive to a negative value again using a structure case

    Hello

    I a VI that takes place (not shown) DAQ hardware and want to do the following with it:

    By feeding the starting value (the maximum negative value of voltage), increase (positive) and the end value (maximum positive) voltage for the DAQ hardware TRADERS (should be

    shown in the digital display) should go to gradually change from negative to positive maxima and do the reverse process of return to the starting value

    which is the maximum negative value.

    for example

    If I put - 3V to the starting value, 0.5 as increment, + 3 V to the end value, I should get the following:

    -3, -2,5, 2,...,.0,..., 2.5, 3 and then 2.5, 2..., 0,...,-2, 2.5-3, then stops.

    I managed to get the first which is negative to positive Maxima but he never do otherwise. Can anyone help with this.

    Thank you very much

    Alain

    Study the attached example.  Instead of having just a graph showing each DC voltage at each iteration, I made a graph that will update to show all the steps as they occur.  The waveform that is the scale of things is to properly size the chart so you can see each stage without having the graph resize with each iteration of the loop.  You can pass values to your DAQ hardware to get the real exit.

    I used a second shift for such direction suggested by Altenbach register.  It is to go to the best (maybe the only way).

  • BUG? (%) Dial and dial gauges return odd if negative values of numbers

    Using AnyChart 5 and Apex 4.0

    When using a Dial gauge (percent), I'm trying to measure quarter percentage growth during the quarter.

    Tell me Yes we have sales of $100 in the 2nd quarter of 2009 and the sale of $80 in the 2nd quarter of 2010.

    We should see a percentage of 20% growth.

    My query returns a single line as for the gauge. However the gauge indicates 1%. Positive rather than negative.

    When I run my query in TOAD and APEX SQL WORKSHOP I get the OK - 20%.

    So I pull the XMLfile URL on the < embed > tag and drop it in my browser. The XML returned with a positive 1 as the value of the gauge pointer. Because the XML generated by the apex_util.flash procedure, I'm guessing that there is a bug?

    XMLfile = "http://apex.server.com:PORT/pls/apex/apex_util.flash?p=108:5:3130601357809295:FLOW_FLASH_CHART5_R5524931725885645_en."

    generated:

    ... < type pointer = "needle" value = "1" color = "0xF1683C" >...

    I even tried to make the series ' SELECT-20, max_val 100, low_val-100, 100 hi_val OF THE DOUBLE ' and then got a positive 1% on the dipstick?

    ---------
    Published by: WannaRock on August 3, 2010 14:16
    ---------
    Tried to switch to a regular dial as opposed to dial (percent). But then, any value should be returned, the dial has returned a value of-99. I need to try a few things and update this post...

    -----
    Published by: WannaRock on August 3, 2010 14:26
    -----
    Seems to be a problem when there is a negative value, AND you specify a up/down column in your query. IF I delete the columns high and low of the query, I get the right numbers when they are positive values. But the negatives do not return (for example, I had a 1% where I should have gotten a-84%). Strange behavior.

    Hi Walter,

    You hit a limitation where gauge cards currently do support the display of positive values. However, this restriction has been removed for Flash 5 graphics and support for the display of negative values on the gauge cards will be included in our next release. This issue is followed by bug 10024437.

    In the meantime, you will have to customize your chart XML in order display negative values. This would require that you replace the chains of substitution #SCALE_DATA # and #DATA # in the custom with your own and area of XML information.

    Kind regards
    Hilary

  • REGEXP_REPLACE - Exclude ONLY zeros if there is between a character and numeric value [1-9]

    Hi all

    I need your help in providing me the regular expression to exclude zeros only if it sits between the characters and a nonzero numerical value.

    For example:

    PL032 = > PL32

    GDP500 = > GDP500 (should remain is that the zeros are not between a character and not null)

    SOA008 = > SOA8

    GDP000 = > GDP0 (only exception: If that's all the 000 and then convert it 0)

    Thank you for your help in advance.

    Kind regards

    Emeline

    Hi, emeline,

    1000877 wrote:

    Hi all

    I need your help in providing me the regular expression to exclude zeros only if it sits between the characters and a nonzero numerical value.

    For example:

    -ONLINE PL32 PL032

    GDP500-online GDP500 (expected to remain is that the zeros are not between a character and not null)

    SOA008-ONLINE SOA8

    GDP000 => GDP0 (only exception: If that's all the 000 and then convert it 0)

    Are characters.  When you say "between characters and numeric value", do you mean "between non-numeric characters and numeric characters?

    If so:

    REGEXP_REPLACE (str,

    '(\D)0+(\d)'

    , « \1\2 »

    )

    \D (with a capital D) means any non-digit character.

    \d (with a small d) means any numeric characters, including 0.  Because regular expressions are greedy by default, "0 + 'match all ' 0' if some other number follows, but leave the last '0' (as you want) then there is not another number immediately after him."

  • Items purchased and it appears I have got only the part of editing photos and movies. How can I get part 2 of my order?

    Items purchased and it appears I have got only the part of editing photos and movies. How can I get part 2 of my order?

    Please post related queries from Photoshop Elements

    http://forums.Adobe.com/community/photoshop_elements

Maybe you are looking for

  • Is there any variety of ransomware that targets Apple?

    I hear more and more about ransomware in the news. It is a software that blocks computers until the ransom is paid. I can't find any reference to what happens to Apple users. Am I missing any report? I must have some form of backup?

  • HP 250 G4 N3050: drivers hp 250 G4 N3050

    Hello I need drivers for hp 250 G4 laptop N3050. Operating system is Windows 7 (64-bit). Thank you Laptop does not recognize the usb key and cannot connect to the internet. I think I'll install the drivers with the cd - dvd (what kind of file should

  • I downloaded a video from Age Of Mythology heaven and I can't open it.

    When I double click it, it says that he doesn't know what program to use to run it. The file is a .rec and this was the first time I downloaded a video from heaven of the AOM. Do I need a driver or something?

  • I tried to recover my chromebook, but it keeps failing.

    I followed the instructions here: https://acer.custhelp.com/app/answers/detail/a_id/27637#_ga=1.91117849.2058217069.1472158467 I went to the site from Google and downloaded the linux script that creates bootable USB support. He passes the verificatio

  • Downloaded updates and mu vista went to classic windows and can not change back

    I don't know much about computers, yesterday my computer automatically installed update, I have vista Home premium.After the updates installed all this changed windows classic style.I went to customize to move to vista and received this messageImposs