Get the max value with other areas

Hi all

I have a table as below

Value name
- - - - - - - - - - - - - - - -
A1 5
A3 10
A2 7
A2 9
A1 10

What I get is the max (Value) and with the consolidation of its name

Value name
- - - - - - - - -
A2 16

Thank you
Alex

Published by: user8606416 on June 1, 2011 10:17

Published by: user8606416 on June 1, 2011 10:26

Depends on how you feel on one of the links of:

SELECT name, value
FROM (SELECT name, SUM(value)
      FROM table
      GROUP BY name
      ORDER BY 2 DESC)
WHERE rownum = 1

SELECT name, SUM(value)
FROM table
GROUP BY name
HAVING SUM(value) >= ALL (SELECT SUM(value)
                          FROM table
                          GROUP BY name)

among many other methods. The first takes a single arbitrary registration in the case of a tie, and the second shows all the related records.

John

Tags: Database

Similar Questions

  • How to get the Max value with other columns data also.

    Suppose that a query is covered with the data as

    Time of ID
    01 07/12/2014
    02 07/05/2014
    03 16/07/2014
    04 07/07/2014

    I need to get the ID and time to time max.
    that is, should I get
    Time of ID
    03 16/07/2014

    To do this, I wrote a query that gives me necessary data. But I thought that's the best way?
    Is it an effective way to get this data?
    My query that returns the data required is:

    SELECT ID, MAX_DT FROM
    (
    Select 'DUMMY', ID, TIME1, MAX (TIME1) OVER (PARTITION 'DUMMY') AS MAX_DT FROM TAB1
    WHERE ID IN (BLAH BLAH)
    )
    WHERE MAX_DT = (EDT) 1

    Frank mentioned links


    WITH test_data (id, time) LIKE)

    SELECT 01, to_date('2014/07/12','yyyy-mm-dd') FROM dual

    UNION ALL

    SELECT 02, to_date('2014/07/16','yyyy-mm-dd') FROM dual

    UNION ALL

    SELECT 03, to_date('2014/07/16','yyyy-mm-dd') FROM dual

    UNION ALL

    SELECT 04, to_date('2014/07/07','yyyy-mm-dd') FROM dual

    )

    SELECT id, time

    go (select id,

    time,

    Max (Time) on latest_time (order by time lines between unbounded preceding and following unbounded)

    of test_data

    )

    where time = latest_time

    ID TIME
    3 16/07/2014
    2 16/07/2014

    Concerning

    Etbin

  • How to get the Max value in Essbase

    Hello

    I have problem to get the max value of 3 years in Essbase.
    How can I get the max value of Dec 2009, Dec 2010, Dec 2011.
    Suppose the value of Dec 2009 = 1000, dec 2010 = 1500 and Dec 2011 = 2000
    I want to get the max value of these three value, how can I do this in the Essbase calculation Script.
    Any idea?


    Thank you.

    Kind regards

    Joni

    You did not specify if year and period are there separate dimensions, in any case as always a number of different possbilities and I don't have much time today to think about, but only one method can be to use @MAXRANGE

    DIFFICULTY (other members to set, 'Dec')

    'MemberToStoreAgainst' = @MAXRANGE("MemberToFindMaxRangeFor","2009:"2011");

    ENDFIX

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • Get the Max values and average of the different cycles in the single channel

    Hello

    I'm trying to get the Max values and average of the single channel that has different cycles it contains. I tried to use commands such as Chnclasspeak3 and chnpeakfind, but they were not useful for me. What I need is the Max values and average of the different cycles numbers saved in the data channel.

    Exampld if the string contains 5 numbers of repetitive cycles, then we must find the maximum values and the average of these 5 cycles in the single channel. Attached reference data. This is the .raw file and I have the plugin for it to use in diadem 11.1.

    Kind regards

    X. Ignatius

    Hello, Ignatius,.

    Sorry, it took some time to provide a replacement based on the script for the function. Please take a look at the attached script. I changed the script to use my function if the tiara-version is less than 12. My script function is not as fast and more stable than the implementation of tiara, but for now, it does the job

    Andreas

  • Get the MAX value of dimension 2 table

    I have a little trouble to find a value MAX (or MIN) of the second dimension in a 2-dimensional array. I do a query and the first dimension is the column name, the second is the values. I'm coming out of the MAX value of the column in the second dimension. ArrayMax said "the array passed cannot contain more than one dimension."

    Any ideas? I'm sure that this is possible.

    MaxValue = ArrayMax (QueryName ["FieldName"]);

    or Q of Q.

  • How to get the numeric values with SCPI on an AG7034B

    Hello

    I use an Agilent 7034 osciloscope with 4 analog and 16 digital channels.

    Read analog channels is no problem, but how do I get the digital channels (101010) waveform?

    I see the digital signal on the screen of the instrument.

    And: I want to do with SCPI commands and read/write Visa.

    Thanks for all tips

    Do you really mean the DSO7034B? If so, there are drivers available for LabVIEW and other programming environments. I suggest you only start with one of these. Check your manual to become familiar with the controls.

    PS ad to the digital I/o Board is incorrect.

  • get the max value date in plsql

    My data in the table are like that

    Date Col1, Col2
    01/01/2012 A01 100
    01/01/2012 B01 200
    01/01/2012 C01 200

    01/02/2012 C01 100

    01/03/2012 B01 100


    I want to show the result of the query with carry on data like this

    01/01/2012 A01 100
    01/01/2012 B01 200
    01/01/2012 C01 200

    01/02/2012 A01 100
    01/02/2012 B01 200
    01/02/2012 C01 100

    01/03/2012 A01 200
    01/03/2012 B01 100
    01/03/2012 C01 100

    Please help me.

    Hello

    Welcome to the forum!

    If not, post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the results desired from these data.
    Explain, using specific examples, 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 {message identifier: = 9360002}

    I think you want an outer join partitioned (to make sure that all dates are represented for all values in col1) and the analytical LAST_VALUE function, like this:

    WITH     all_dates     AS
    (
         SELECT DISTINCT  dt     -- DATE is not a good column name
         FROM              table_x
    )
    SELECT       a.dt
    ,       x.col1
    ,       LAST_VALUE (col2 IGNORE NULLS) OVER ( PARTITION BY  x.col1
                                                    ORDER BY      a.dt
                                   )           AS col2_shown
    FROM             all_dates  a
    LEFT OUTER JOIN      table_x    x  PARTITION BY  (x.col1)
                                   ON  x.dt = a.dt
    ;
    

    If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.

  • get the max value

    Hi all
    I have the following data
    with table1 as
    (
      select to_date('01/01/2010', 'mm/dd/yyyy') dt, 2 cid from dual
      union all
        select to_date('03/01/2010', 'mm/dd/yyyy') dt, 1 cid from dual
      union all
        select to_date('03/01/2010', 'mm/dd/yyyy') dt, 3 cid from dual
      union all
      select to_date('05/11/2010', 'mm/dd/yyyy') dt, 4 cid from dual
    
    ) 
    I would like to write a query that gives me the dt max with the corresponding id.
    for example, if I specify to_date (April 1, 2010 ', ' dd/mm/yyyy') then the output should be

    CID DT
    ===============
    2010-03-01 3

    If I said on 02/01/2010 then the output should be

    CID DT
    ===============
    01/01/2010 2


    as you can see, I want max < specify the date. I also specify the corresponding cid which belongs to this date
    can someone help me write a query that gives result above
    with table1 as
    (
      select to_date('01/01/2010', 'mm/dd/yyyy') dt, 2 cid from dual
      union all
        select to_date('03/01/2010', 'mm/dd/yyyy') dt, 1 cid from dual
      union all
        select to_date('03/01/2010', 'mm/dd/yyyy') dt, 3 cid from dual
      union all
      select to_date('05/11/2010', 'mm/dd/yyyy') dt, 4 cid from dual
    
    )
    select max(dt) max_dt,
             max(cid) keep (dense_rank last order by dt)  cid
    from table1
    where dt <= to_date('04/01/2010', 'mm/dd/yyyy') -- perhaps you need "<" instead of "<=" here !
    
    with table1 as
    (
      select to_date('01/01/2010', 'mm/dd/yyyy') dt, 2 cid from dual
      union all
        select to_date('03/01/2010', 'mm/dd/yyyy') dt, 1 cid from dual
      union all
        select to_date('03/01/2010', 'mm/dd/yyyy') dt, 3 cid from dual
      union all
      select to_date('05/11/2010', 'mm/dd/yyyy') dt, 4 cid from dual
    
    )
    select max(dt) max_dt,
             max(cid) keep (dense_rank last order by dt) cid
    from table1
    where dt <= to_date('01/02/2010','mm/dd/yyyy')  -- perhaps you need "<" instead of "<=" here !
    

    Published by: hm on 25.10.2010 12:57

  • How can I get the max of a measurement value

    How can I get the max of a measurement value?

    http://forums.NI.com/T5/LabVIEW/how-can-I-return-the-maximum-value-from-a-voltage-sensor-over/m-p/30...

    I tried the while loop max-min-solution described in this link. But this using my myRio acceleration measurement no longer works. It seems to hang.

    I use the I2C Communication.

    The inner circle while loop is a bad construction.  It will be either executed once, if enter the Boolean value is True, or forever if the value is false.

    Put your records on the timed loop shift and eliminate inside while loop.  Then your code should work.

  • When we try to create a shape with a predefined size above 10 x 10 inches of ps cs6, we get the next value in A message between 0.00 10.00 inches and thumb is necessary.  Close value inserted.

    When we try to create a shape with a predefined size above 10 x 10 inches of ps cs6, we get the next value in A message between 0.00 10.00 inches and thumb is necessary.  Close value inserted.

    You could put in your dimensions in the boxes of fixed size .

    Then just click on you document and move the object slightly before releasing the mouse if you don't get this pop up dialog box to create a Rectangle rounded.

  • How to get the Max of elements of type datetime value

    Hi all
    I wanted to get the last value timestamp (DateTime data type) of the node list. I have the following xml. In this xml file, I want to get the modifydate element that has the last time stamp via xquery/xpath, it should return me following result 2011-09-29 T 17: 21:17 + 10:00

    < CustomerList >
    < CustomerDetails >
    < Name > Test 1 < / name >
    assets of < status > < / status >
    < modifyDate > 2011-08-20T 17: 21:17 + 10:00 < / modifyDate >
    < / CustomerDetails >

    < CustomerDetails >
    < Name > Test 2 < / name >
    Cancel < status > < / status >
    < modifyDate > 2011-08-29T 17: 21:17 + 10:00 < / modifyDate >
    < / CustomerDetails >

    < CustomerDetails >
    < Name > Test 3 < / name >
    assets of < status > < / status >
    < modifyDate > 2011-09-29T 17: 21:17 + 10:00 < / modifyDate >
    < / CustomerDetails >
    < / CustomerList >


    I tried to use the
    CustomerList/CustomerDetails/modifyDate [not (. < =... / the above - sibling:CustomerList/CustomerDetails modifyDate) and not (. < =... / following - sibling:CustomerList/CustomerDetails modifyDate)]
    But it does not work on the datetime data type.
    Any help in this regard is highly appreciated.

    Concerning

    Published by: user6736659 on Sep 5, 2011 06:15

    Hello

    The following XQuery query should give you what you want:

    max(
     for $i in /CustomerList/CustomerDetails/modifyDate
     return xs:dateTime($i)
    )
    

    For example, by using Oracle SQL:

    SQL> var xmldoc varchar2(4000)
    SQL> begin
      2   :xmldoc := '
      3  
      4   Test 1
      5  active
      6  2011-08-20T17:21:17+10:00
      7  
      8
      9  
     10   Test 2
     11  cancel
     12  2011-08-29T17:21:17+10:00
     13  
     14
     15  
     16   Test 3
     17  active
     18  2011-09-29T17:21:17+10:00
     19  
     20  ';
     21  end;
     22  /
    
    PL/SQL procedure successfully completed
    
    SQL> select xmlquery('max(
      2   for $i in /CustomerList/CustomerDetails/modifyDate
      3   return xs:dateTime($i)
      4  )'
      5  passing xmltype(:xmldoc)
      6  returning content
      7  )
      8  from dual
      9  ;
    
    XMLQUERY('MAX(FOR$IIN/CUSTOMER
    --------------------------------------------------------------------------------
     2011-09-29T17:21:17.000000+10:00
     
    
  • Is it possible to get the total value of column and set to another area

    Hello

    Is it possible to get the total value of a particular column, and assign this value to another discipline?

    How to do this?

    Thanks in advance,
    SAN

    Hi SAM,

    If your controller class throw this message it means that it works very well. Follow these steps, I hope this will solve your problem.

    1 check the following

    OAApplicationModule am = pageContext.getApplicationModule (webBean);
    OAViewObject ratvo = (OAViewObject) am.findViewObject("*CompetenceElementsVO*"); It should be the name of the instance instead of the name Physics vo vo.
    OAViewObject valuevo = (OAViewObject) am.findViewObject("*PerRatingLevelsVO*");

    2. extend this controller class that is associated with this region.

    I hope it will work now.

    Haroon.

  • Update based on the max value of different tables.

    {code}

    create the table rule_table (number rule_id);

    insert into rule_table values (10);

    insert into rule_table values (20);

    insert into rule_table values (30);

    insert into rule_table values (40);

    create the table auth_table (number of auth_id, rule_id number);

    insert into auth_table values (1000, 10);

    insert into auth_table values (2000, 10);

    insert into auth_table values (3000, 10);

    insert into auth_table values (4000, 20);

    insert into auth_table values (5000, 20);

    insert into auth_table values (6000, 30);

    insert into auth_table values (7000, 30);

    insert into auth_table values (8000, 40);

    insert into auth_table values (9000, 40);

    create the table pay_table (pay_id number, auth_id number, pay_indicator number);

    insert into pay_table values (11111, 1000, 0);

    insert into pay_table values (22222, 1000, 1);

    insert into pay_table values (33333, 1000, 0);

    insert into pay_table values (44444, 2000, 0);

    insert into pay_table values (55555, 2000, 1).

    insert into pay_table values (66666, 2000, 0);

    insert into pay_table values (77777, 3000, 0);

    insert into pay_table values (88888, 3000, 0);

    insert into pay_table values (99999, 4000, 0);

    insert into pay_table values (111111, 4000, 0);

    insert into pay_table values (222222, 5000, 0);

    insert into pay_table values (333333, 5000, 0);

    insert into pay_table values (444444, 6000, 0);

    insert into pay_table values (555555, 7000, 1);

    insert into pay_table values (666666, 8000, 0);

    insert into pay_table values (777777, 9000, 0);

    insert into pay_table values (888888, 9000, 1);

    create the table rule_pay (rule_id number, pay_max_indicator number);

    insert into rule_pay values (10, 0);

    insert into rule_pay (20, 0) values;

    insert into rule_pay (30, 0) values;

    insert into rule_pay (40, 0) values;

    {code}

    My intention is:

    for every find of rule_id on the maximum pay_indicator (tables 3 query to get the max Show pay_indicator below) and on the other table I have to update this value max based on rule_id.

    with max_tab

    as

    (

    Select a.rule_id, max (pay_indicator) pay_indicator

    rule_table a.,

    b auth_table,

    c pay_table

    where a.rule_id = b.rule_id

    and b.auth_id = c.auth_id

    A.rule_id group

    )

    Update rule_pay

    Set pay_max_indicator = (select max_tab.pay_indicator

    of max_tab

    where max_tab.rule_id = rule_pay.rule_id)

    where

    rule_id in (select rule_id from max_tab);

    The above query does not.

    Any help or suggestions are greatly appreciated.

    Something like that?

    SQL > select * from rule_pay;

    RULE_ID PAY_MAX_INDICATOR

    -------------------- --------------------

    10                    0

    20                    0

    30                    0

    40                    0

    SQL > fusion in rule_pay PR

    2. using (select a.rule_id, max (pay_indicator) pay_indicator

    rule_table 3A,

    auth_table 4 b,

    pay_table 5 c

    6 where a.rule_id = b.rule_id

    7 and b.auth_id = c.auth_id

    Group 8 by a.rule_id

    9        ) u

    10 on (u.rule_id = rp.rule_id)

    11 when matched, then update

    12 set rp.pay_max_indicator = u.pay_indicator

    13;

    4 lines merged.

    SQL > select * from rule_pay;

    RULE_ID PAY_MAX_INDICATOR

    -------------------- --------------------

    10                    1

    20                    0

    30                    1

    40                    1

    BTW, you can't put a WITH clause before an update.  It can only precede a select statement.

  • Get the highest value of acquired data

    Hi, how can I get the highest value of data according to data acquired using the accelerometer ADXL345 and LINX in LabVIEW?

    I want the highest data to be shown with a flag. However, the data being shown are always the last acquired data. My problem would be what happens if the highest data somewhere at the beginning or in the middle of all the acquired data? How to display the highest data using an indicator?

    Here's a look at my front, block diagram, and sample of the acquired data.

    From the front panel, the basic indicator of detected last poster 0.1929 (amplitude), which is the last value. But looking at the Excel file, the highest data are data which is 0.2013. The highest, I want to be displayed on the indicator not the last value. How do I do that?

    Thank you!

    I gave you an example of what you need to do - it is not okay if wire you the new value and the old value for the X or Y - it will always return the maximum of the two values so the order doesn't matter. It would have been more useful if you had posted what you tried the max & min. You need a registry to offset inside the loop (like I did with my while loop). If you only want to display the maximum value for each iteration of the loop for external, you must initialize the shift register by plugging a 0 to its terminal on the left. A shift register her pinned the value of the last run - probably not what you want here.

  • Find the max value

    Hi team,

    I have the following query where I need to find the max value

    [code]

    with t as)

    Select 'L1' R_nm, R_Data 'Data', 'Obj' R_Obj, r_prec 'Wd', '2' double val

    Union of all the

    Select 'L1', 'Data', 'Obj', 'No', '4' double

    Union of all the

    Select 'L2', 'Data', 'Obj', 'No', '4' double)

    Select t.*, max (val) on rk (partition r_nm, r_data, r_obj) of t

    [/ code]

    My results should be

    [code]

    r_nm r_data r_obj r_prec rk val

    L1 Data Obj 1 2 Wd

    L1 data Obj 4 No.2

    L2 Data Yes 1 1 Obj

    [/ code]

    Thank you


    Hello

    It seems that you are not interested in the MAX at all.  Looks like you want to classify the lines, such as one that has the lowest value is assigned the number 1, the 2nd line with the lowest values gets 2,... and line with him gets N-th lowest value N.  If is not serious if the MAX is 4, 2 or 420.

    Here's a way to do it:

    SELECT T.*

    , RANK () OVER (PARTITION BY r_nm, r_obj)

    ORDER BY val

    ) AS rk

    T

    ORDER BY r_nm, r_obj

    val

    ;

    Depending on how you want to deal with links, you can use ROW_NUMBER or DENSE_RANK instead of RANK.

Maybe you are looking for

  • Compaq Presario CQ57: bios error 501

    What should I do to get rid of this problem?  Please help me someone.

  • HP Pavilion DV7-4120em recovery

    HelloHP Pavilion DV7-4120em laptop in the family for quite a few years now. It was adopted for my use now of my father. Sometimes for the use of my father to the laptop, it went through a repair, and all the hard drive has been replaced with a versio

  • Windows Update does not not os-windows7 starter

    erased the hard disk using dban, clean install windows 7 edition starter, installed bit defender and IE 11, windows updates does not work can not update, computer hp mini 110.  Please help Mark

  • ATI Mobility Radeon X 1400 with the problem of the TV, only the black and white photo

    Hello When I try to connect my TV to my Dell Inspiron 6400 with ATI Mobility Radeon X 1400 card, all I get is a black and white image. I have tride all the PAL settings. What I tried: I connected the s-video with an s-video cable output to my TV s-vi

  • Archive log deletion with no backup of the archive logs

    I suffer from enormous size archive of the newspaper. In my previous post, I asked for help. I almost 480 GB archive log every day in our database of 11 2 under redhat linux 5.8 GR. Now, if you please help me in another case. If I take backup of arch