Second most high and the third lowest value in columns

create table test (id number, a number, number of b, c number d, e number);
insert into test values (1,13,8,7,14,15);

Power required with column names more high and 3rd lowest value 2
ID           2NDHIGHEST        3RDLOWEST
---------    ----------        ---------
1            14[D]             13[A]
Thank you.

Tags: Database

Similar Questions

  • Second most high and the second lowest value in columns

    Oracle 11.2.0.1
    Windows
    create table test (id number, a number, b number, number c number d);
    insert into test values (1,20,23,38,15);
    insert into test values (2,0,18,18.1,19);
    Insert test values (3.40,-2, 25.67, 28);
    SQL> select * from test;
    
            ID          A          B          C          D
    ---------- ---------- ---------- ---------- ----------
             1         20         23         38         15
             2          0         18       18.1         19
             3         40         -2      25.67         28
    Power required:
    ID         2ndHighest 2ndLowest
    ---------- ---------- ----------
    1          23         20
    2          18.1       18 
    3          28         25.67
    Thank you.

    user12050217 wrote:
    Thank you. What happens if I want to add column names too with the value as indicated above, please.

    Decode a more

    with test_result as
    (
    select t.*,
           case greatest(a,b,c,d)
                  when  d then greatest(a,b,c)
                  when  c then greatest(a,b,d)
                  when  b then greatest(a,d,c)
                  when  a then greatest(d,b,c)
           end g2,
           case least(a,b,c,d)
                  when  d then least(a,b,c)
                  when  c then least(a,b,d)
                  when  b then least(a,d,c)
                  when  a then least(d,b,c)
           end l2
    from test t
    )
    select id,g2||decode(g2,a,'[A]',b,'',c,'[C]',d,'[D]') g2,l2||decode(l2,a,'[A]',b,'[B]',c,'[C]',d,'[D]') l2 from test_result;
    
    
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                
    
  • Slower call to VI on the second and the third iteration

    Hi all

    Anyway, I'm going to build a program that takes 1 d tables and the concatenates a table 2D where I take the average/mode/etc of each column and represent the single result as a 1 d array.  I placed this part of the code in another VI done a terminal connector and so on.  I placed this VI in a state machine and what I call whenever 'the State' is activated, when I call the VI for the first time, it's fast and responsive (10 seconds to produce the data), once it's over the state machine continues in another State, and once I call this state again the VI will take 20-30 seconds If I do this a third time, it may take up to 5 minutes to produce the data.  Whenever I call the VI I provide arrays of the same length and the calculations should be very very similar, it is possible that the VI "organizes" data in his paintings and they build to be longer and longer whenever I call him?  If so is it possible to delete all the variables and to start all the tables from the beginning again?

    I guess I'm new on the manipulation of data (most of my work is in hardware configuration), but please if someone has any advice that has be great!

    I can post a demo if program would,.

    Thank you.

    My main thought is that you build your table and concatinating on your previous table.  As we have already said, this is probably a registry to uninitialized lag or something similar.  Post the VI will allow us to more easily debug.

  • How can 1 derive / display 3 second interval lines from the existing timestamp values

    Hello

    I'm trying to produce the number of lines that occur in intervals of 3 seconds and cannot work out how to use the timestamp values existing in the table of products or the display of lines with a second gap 3? The table rows look like this:

    NAME (EDT) 1

    1111 JANUARY 30, 15 12.29.09.000000000

    PPPP JANUARY 30, 15 12.29.10.000000000

    PPPP JANUARY 30, 15 12.29.11.000011111

    1111 JANUARY 30, 15 12.29.11.000055555

    PPPP JANUARY 30, 15 12.29.17.000000000

    PPPP JANUARY 30, 15 12.29.18.000000000

    1111 JANUARY 30, 15 12.29.29.000000000

    PPPP JANUARY 30, 15 12.30.23.000000000

    PPPP JANUARY 30, 15 12.30.25.000000000

    1111 JANUARY 30, 15 12.30.27.000000000

    PPPP JANUARY 30, 15 12.30.29.000000000

    PPPP JANUARY 30, 15 12.30.31.000000000

    1111 JANUARY 30, 15 12.30.33.000000000

    PPPP JANUARY 30, 15 12.30.35.000000000

    PPPP JANUARY 30, 15 12.30.37.000000000

    1111 JANUARY 30, 15 12.30.39.000000000


    And the output that I'm trying to reach/drift (initially) is as follows:


    Timestamp1                            Count

    30 JANUARY 15 12.29.09 4

    JANUARY 30, 15 12.29.12 0

    JANUARY 30, 15 12.29.15 1

    JANUARY 30, 15 12.29.18 1

    JANUARY 30, 15 12.29.21 0

    JANUARY 30, 15 12.29.24 0

    JANUARY 30, 15 12.29.27 1

    JANUARY 30, 15 12.29.30 0

    JANUARY 30, 15 12.30.30 1

    JANUARY 30, 15 12.30.33 1

    JANUARY 30, 15 12.30.36 1

    JANUARY 30, 15 12.30.39 1


    Thus, the main problem that I see trying to derive the first column of numbers as shown above. If someone could give me help on this I would be very grateful.


    Kind regards


    Kevin.


    with (name, time 1) testdata until)

    Select "1111", to_timestamp (January 30, 15 12.29.09.000000000', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "PPPP", to_timestamp (January 30, 15 12.29.10.000000000', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "PPPP", to_timestamp (January 30, 15 12.29.11.000011111', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "1111", to_timestamp (January 30, 15 12.29.11.000055555', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "PPPP", to_timestamp (January 30, 15 12.29.17.000000000', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "PPPP", to_timestamp (January 30, 15 12.29.18.000000000', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "1111", to_timestamp (January 30, 15 12.29.29.000000000', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "PPPP", to_timestamp (January 30, 15 12.30.23.000000000', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "PPPP", to_timestamp (January 30, 15 12.30.25.000000000', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "1111", to_timestamp (January 30, 15 12.30.27.000000000', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "PPPP", to_timestamp (January 30, 15 12.30.29.000000000', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "PPPP", to_timestamp (January 30, 15 12.30.31.000000000', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "1111", to_timestamp (January 30, 15 12.30.33.000000000', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "PPPP", to_timestamp (January 30, 15 12.30.35.000000000', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "PPPP", to_timestamp (January 30, 15 12.30.37.000000000', 'dd-mon-yy hh24:mi:ss.ff') of all the double union

    Select "1111", to_timestamp (January 30, 15 12.30.39.000000000 ',' dd-mon-yy hh24:mi:ss.ff "") of the double

    )

    , d (mn, mx, cnt) as)

    Select min (time1) - second "3" interval

    , max (time1) - interval of second '3'

    ,      -1

    of testdata

    Union of all the

    Select

    MN + interval of second '3'

    mx

    , (select count (*) in testdata where time1 > = mn + '3' second interval and time 1)< mn="" +="" interval="" '6'="">

    d

    where mn<=>

    )

    Select

    MN

    cnt

    d

    where NTC! = - 1

    Mn, mx, NTC group

    Agenda minutes;

  • extraction to a minimum and the next minimum value in each row of a matrix

    Hello

    I need to get a minimum and the minimum value next to each line of a matrix of dimension 2.

    I could extract successfully the minimum value, but failed to get the next minimum.

    Here is a screenshot of how I arrived at the minimum value

    Conversion matrix at table then use the leaderboard

  • Difference between the intensity and the gray scale value

    Hi I am a new learner of vision of NOR, please bare with me.

    1. I'm quite confused by the terms of light intensity and pixel gray scale value. Can someone explain the difference to me? Or are they the same thing?

    2. I'm currently treat an image in grayscale (I16) file. The number of bits of the image is 12 Bits. But I saw that someone used IMAQ polygon with the number of Classes as 8192 (13 Bit), don't know why.

    Thank you, Jane

    Hello Jane,.

    1 OK, grey scale and intensity are the same thing.

    2. the number of class you choose is an appeal from the judgment.  By increasing or decreasing the number of more or less granular classes, the histogram becomes.  Without a context, I can't speculate on why someone use 8192 classes.

    David has

  • Select from a drop-down list and the specified element values are displayed in the textfield

    I need for one to be able to select from a list drop-down and specified the item values appear in textfield.

    For example, if I select Amy

    If I select Bob

    If I select Jane

    Amy

    Bob

    Jane (I want to appear as shown in the list)

    I associated a value to each item in the drop-down list so that the choice is easy to compare and determine what initial (default) value to the value in the text field. In my drop down list change event, I have the following:

    var sNewSel = this.boundItem (xfa.event.newText);

    Switch (sNewSel)

    {

    case '1': / / Amy

    TextField1.rawValue = "Amy \n";

    break;

    Switch (sNewSel)

    {

    case '2': / / Bob

    TextField1.rawValue = "Bob \n";

    break;

    Of course that's not work one name shows at a time. Help, please!

    Thank you

    Don't know what the code is supposed to do, but basically, you want to add the name of the drop-down list the addition on the current value of the TextField? Why not use the dropdownlist display value directly? For example on the change event:

    if ( TextField1.rawValue == null )
        TextField1.rawValue = xfa.event.newText;
    else
        TextField1.rawValue += ( "\n" + xfa.event.newText );
    
  • How to create parameters and the list of values in BI Publisher

    Hello friends,
    I use BI Publisher 10.1.3. I tried to create a report based on the data of a column for ex: dept_no
    in the data model, I specified the name of the table to select all columns
    I created the list of values taken as a query sql-type. in the query I wrote dept_no Department selection
    In the settings section I gave him as an integer value, and by default as * parameter type in the menu then I chose the name list the value that I've previously specified...
    now the problem is when I run the report I receive all data despite selecting the parameter I need particular data of this deptno
    What could be the reason
    pls let me know
    Thanks and greetings

    In your main data model query, you use this parameter to limit the data for the selected service?

    For example. Select dept_name of departments where dept_no =: p_dept

    where: p_dept is your parameter...

    Thank you!

  • Is it possible to have Firefox 4 speed while keeping the menu much higher and the bar tab of Firefox 3?

    I want to increase the operating speed, but for my use of the new orientation of the tab bar, tabs favorite and engine of research would be counterproductive.

    It is very easy to do. By default on Windows XP, it will have the old style menu bar and the tab bar is not on top.

    If you have Firefox 4 put in place with the new UI, you can return to the older appearance by right-clicking a toolbar, then clicking on the entrance to the "Menu bar" to select. To change the position of the tab bar, right-click on a toolbar and click the entry "Tabs at the top".

  • validation and the missing input value

    I must have missed something, but right now I have no idea.

    Need to do a validation on a P10_ID element. This validation should take place at any time when the user presses a button of validation.

    I created a conditional are validation when you press the VALIDATEID. It worked (is a msg of error issued when not) but the value of the id registered users still missing during the validation has taken place. How can I keep the stay of value on the screen? There is no reset on page page action.

    Thank you.

    Tai

    Hello

    Your value is 'lost' because the automatic extraction of line always replace the value of the element

    Kind regards
    Jari

  • Apex maintain control checkbox and definition of a value in column

    Apex 4.2

    I am having trouble with checkboxes. I have pseudocoded the process, but don't know how to implement using checkboxes. Here's the full story:

    I have an interactive report based on the ORGANIZATIONS Table on Page 1

    ORGANIZATIONS

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

    ORG_ID PK

    NOM_ORG

    ORG_TYPE

    QA_DATE

    On the data entry page (Page 2), a user can fill out the org name and type of the org. There is also a checkbox the user can click / check once they have done their research on the Organization and approved. Checking this box should assign the QA_DATE the SYSDATE.

    Then Page 2 would have the following on the page:

    P2_ORG_ID

    P2_ORG_NAME

    P2_ORG_TYPE

    P2_CHECKBOX

    I thought that when I submit the page, I might have a pl/sql process that indicates if the box is checked, update table ORGANIZATIONS and SET the QA_DATE the SYSDATE.

    I'm not sure how:

    -Handle to check if the box is checked.

    -What are the values in the LOV to the checkbox control if necessary

    -Or how to keep or keep the checkbox check once you leave the page

    I also thought it would be a process ON LOAD to Page 2 affecting the checkbox "checked" to the QA_DATE IS NOT NULL. This is my best solution for the maintenance of the box since it's a page element.

    Any help at this Summit would be greatly appreciated. Thanks in advance for your help.

    NewApexCoder

    In your situation, the list of STATIC values example:; Y (show just the box and return Y) is most appropriate.

    This will show the box and when activated that the value of the element is disabled. the value will be null.

    Because the box is not a column of data, it doesn't really matter what you choose as a return value, as long as you are consistent. Using of Y as used return value makes sense in this case.

    For the holding of the box checked after submit. Have QA_DATE as part of page too (P2_QA_DATE) with the column of database for the source type. Then to P2_CHECKBOX have the original "PL/SQL Expression" with source type case when QA_DATE is null, null, then else 'Y' end. This check if there is a QA_date and uncheck the box when the column is empty.

    You can use a calculation on 'Send' to set P2_QA_DATE when P2_CHECKBOX is there. And use the DML Wizard process generated to do the update.

    In general the checkbox element can display several checkboxes for example:

    select dep.department_name, dep.department_id
    from   oehr_departments dep
    

    as lov displays a check box for all departments with the name of the Department as the option label.

    All return values in the form of active boxes a colon delimeted string.

    Show with the lov above with the following entry

    10 administration

    20 marketing

    Purchase 30

    If you check the Administration and the purchase of the value of the element will be 10:30.

    See this example for fun with a checkbox.

    Nicolette

  • ALTER Table of the default Oracle and the length of name of column Type

    Hi all

    I want to increase the length of the table names and the names of the columns in Oracle.

    By default, it is set like this:

    SQL > dba_tab_columns desc;

    TABLE_NAME NOT NULL VARCHAR2 (30)
    COLUMN_NAME NOT NULL VARCHAR2 (30)
    ...

    Is it possible to change the VARCHAR2 (30) to VARCHAR2 (100)?

    Published by: sukrandere on 12:21 10.Mar.2010

    Table names and column are all two identifiers
    According to the documentation, the maximum length of an identifier is 30 characters.
    It is hard coded in the database software and you can't change it.
    Or do you need to change.

    ---------------
    Sybrand Bakker
    Senior Oracle DBA

  • Web client - System Configuration node displays 'Unknown' for the Uptime and the workload, no value for IP &amp; Hostname

    When I connect on our vCenter 6 Update 1 device (embedded PSC) via the Web Client with integrated Active Directory ID, select "System Configuration", then select the node for vCenter, summary screen displays all the information IP or host name.  In addition, the status of availability and workload for storage/memory/swap/load of work view all 'unknown '.  See attached photo for reference.

    All values under management-> settings are also empty.

    When I login with [email protected], all the above values are displayed and I can change the settings of the device of vCenter as expected.  This made me suspect a permission problem exists, but I cannot know what SSO group to add our AD is less to enable management or control of the aircraft from vCenter for that it works as expected.

    Already tried to add our accounts to the following groups in SSO under the vsphere.local domain:

    DCAdmins

    SystemConfiguration.Administrators

    ComponentManager.Administrators

    Directors

    This information on the purpose of each group unfortunately did not help me understand which could apply:

    Groups in the field of vsphere.local

    Thank you very much for the help!

    I just did some digging on this myself (we deployed now U2 6.0) after I tried the same things (adding AD users in the SSO domain groups, etc. etc.) without success.

    What I have found is that it is simply a WELL-KNOWN PROBLEM with 6.0 U2 and maybe they'll fix with U3 6.0 when that comes out (later this summer)?  Maybe it'll be 6.5 at that time, with an announcement to the VMworld 2016 or something - who knows.

    The workaround is a joke--suggesting the deployment using only the SSO domain by default.  Well, which is never going to happen naturally, so he says as a workaround is, if you really need to get and display status, etc. from the web client, you simply connect with your [email protected] account that was created at the initial time of installation.

    VMware vCenter Server 6.0 Update 2 Release Notes

    *****

    Failed to configure and view information about the vCenter Server Appliance by using the System Configuration page in the Web Client vSphere with errors
    Connect to the instance of vCenter server in the vCenter Server Appliance with a user who is located in a custom name (different from the default vsphere.local) Single Sign-On the field by using the Web Client vSphere. On the vSphere Web Client home page, click on the System Configuration and select nodesunder the System Configuration. If you try to change the settings, restart or power off a node of the vCenter Server Appliance, the operation fails with one of the following errors: An internal error has occurred - Error # 1009 and Not authorized to use this API . If you click on the summary, monitoror Manage tabs, some device information cannot be displayed.

    Workaround: deploy the vCenter Server Appliance by using the domain of Single Sign-On by default: vsphere.local.

  • DB link between our client and the third party provider

    There is a third party provider that has its own db containing information on supporting documents.

    There is a link in db between db and db of third-party customer

    Now for our client we create vouchers through the UI in our database that must be verified in third-party provider db and created in our database

    How can achieve us

    Why don't you create a view in your DB which is ' select * from ".

  • Get separate paths and the depth attribute value using the XQuery function

    Hi otn.
    I want to write the function XQuery that accept the following input document nodes.

    < counter Root = "8" >
    < has counter = "3" >
    < meter B '2' = >
    < C meter = "1" >
    < meter D = "1" / >
    / < C >
    < /B >
    < C meter = "2" >
    < counter E = "1" / >
    / < C >
    < /A >
    < meter B = "4" >
    < C meter = "3" / >
    < /B >
    < C meter = "6" >
    < counter E = "3" / >
    < counter D '2' = >
    < counter E = "1" / >
    / < d: >
    / < C >
    < meter D = "2" / >
    < counter E = "4" >
    < counter F = "1" / >
    < /E >
    < counter F = "1" / >
    < / root >

    Then returns many things at the same time as follows:
    1 - list of all of the separate paths
    2 - meter of the depth of each path element attribute value
    3 - the value of the previous counter in 2, is divided by the value of the attribute root counter.

    Thanks in advance :)))

    I'm sorry that not all xml input data correctly.

    You must use the {code} tag to enclose the code snippets. Formatting will be preserved and content not interpreted by the forum software.

    
      
       
        
         
        
       
       
        
       
      
      
       
      
      
       
       
        
       
      
      
      
       
      
      
    
    

    Here's an XQuery query that should work:

    declare function local:list-paths($d as element())
    as element()*
    {
      let $root := name($d)
      let $rootcnt := xs:integer($d/@counter)
      for $i in $d/descendant::*
      return element path
      {
        attribute value {
          substring-after(
            string-join(
              for $j in $i/ancestor-or-self::*
              return name($j)
            , "/"
            )
          , $root
          )
        }
      , attribute counter {$i/@counter}
      , attribute percentage {xs:integer($i/@counter) div $rootcnt}
      }
    };
    

Maybe you are looking for

  • cannot open attachments received?

    If anyone can help? I cannot open most attachments on incoming mail? Mostly photos ETC& ETC

  • Tecra 9100 does not supply power to the top

    Hello I got Tecra 9100 laptop computer and you have a POWER PROBLEM.Basically, it got stuck at the start of the OS and I was unable to click or move the mouse to do something. So I held the power button to turn it off. I do not turn on again entered

  • I guess that's not Apple...

  • HP4276A

    I have downloaded HP4267A of NEITHER. I use a GPIB cable / USB to connect to HP4276A and GPIB address is 17. I tried "HP4276A Example.vi" and a window poped upward, "error 0 occurred to HP4276A Config measure; "HP4276 to send" a Message. " Please giv

  • Feeling of HTC not recognized

    I have a HTC sense and I loaded the latest drivers/software but when I connect the sync software does not recognize the phone. In the settings of the Device Manager there is an exclamation mark next to the android device how to rectify this? I ran wi