How to select a value to a maximum value of another column in the same line?

pVersion pdate pcount
11 1/6 / 2011 1
06/11/2011 0, 25
11 1/6 / 2011 24

How to select for a maximum pcount pversion, in this case count max is 25 and version will be 0?

tcode wrote:
pVersion pdate pcount
11 1/6 / 2011 1
06/11/2011 0, 25
11 1/6 / 2011 24

How to select for a maximum pcount pversion, in this case count max is 25 and version will be 0?

WHERE PCOUNT = (SELECT MAX (PCOUNT) FROM TABLE1)

Tags: Database

Similar Questions

  • How to find a value in any column of the table - essentially a search

    Hi guys,.

    Thanks in advance for your help.

    I'll try to find a value in any column of the table? How can I do?

    An example of value would be "FEDERAL."

    Using Oracle 11 g and SQL Developer.

    Thank you

    It's a question that is asked in the past several times (but not recently from what I remember).

    Michaels has provided in the past, solutions which are quite clever, just using SQL...

    10g of solution

    Michaels > var val varchar2 (5)

    Michaels > exec: val: = "Sub".
    PL/SQL procedure successfully completed.

    Michaels > select distinct substr (: val, 1, 11) "keyword."
    substr (table_name, 1, 14) "table."
    substr (t.column_value.getstringval (), 1, 50) ' / value of the column.
    CLO.
    Table
    (xmlsequence
    (dbms_xmlgen.getxmltype ("select" | column_name))
    || 'from ' | table-name
    || ' where upper (')
    || column_name
    || ') as superior (' %' |: val)
    || '%'')'
    ) .extract (' LINES/rowset / * "")
    )
    ) t
    -where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'SERVICES')
    order of the "Table".

    11g upwards

    SQL > select table_name,.
    column_name,
    : search_string search_string.
    result
    from (select column_name,
    table_name,
    "ora: view("' ||) " table_name | "") / LINE /' | " column_name | "[ora:contains (text ()," %' |: search_string | ")]. (%») > 0]' str
    CLO
    where table_name in ('EMP', 'Department')),
    XMLTable (columns str result varchar2 (10) path '.')
    /

    TABLE_NAME COLUMN_NAME SEARCH_STRING RESULT
    ------------------------------ ------------------------------ -------------------------------- ----------
    DEPT                           DNAME                          es                               RESEARCH
    EMP                            ENAME                          es                               JAMES
    EMP                            JOB                            es                               SALESMAN
    EMP                            JOB                            es                               SALESMAN

    4 selected lines.

  • How to check multiple values with another column?

    Hi all

    create table xxc_abc (col1 , dept_id number number);

    create the table xxc_bbb (col2 number,sa_dept_id number);

    insert into xxc_abc values (1,10)

    insert into xxc_abc values (2,11)

    insert into xxc_abc values (3,12)

    insert into xxc_bbb values (20.10)

    insert into xxc_bbb values (20,11)

    insert into xxc_bbb values (20,12)

    SELCT

    xxc_abc a.,

    xxc_bbb b

    where a.dept_id = b.sa_dept_id

    Expected results

    a.Col1 b.col2

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

    1 20

    2 20

    3 20

    I need to get several values a.col1 with the same value of the b.col2 column

    a.Col1 b.col2

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

    1 20

    2 20

    3 20

    Thank you

    Post edited by: Rajesh123 added Test cases in the main Thread

    Select the number you want to


    with

    xxc_abc as

    (select 1 col1, 10 dept_id in union double all the)

    Select 2,11 Union double all the

    Select double 3.12

    ),

    xxc_bbb as

    (select col2 20, 10 sa_dept_id union double all the)

    Select 20,11 Union double all the

    Select 20,12 double

    )

    Select col1, col2, cnt_all, cnt_not_null, cnt_unique

    from (select a.col1, b.col2,

    Count (*) on cnt_all (b.col2 partition).

    Count (a.Col1) on cnt_not_null (b.col2 partition),

    Count (distinct a.col1) on cnt_unique (b.col2 score)

    xxc_abc a.,

    xxc_bbb b

    where a.dept_id = b.sa_dept_id

    )

    where least (cnt_all, cnt_not_null, cnt_unique) > 1

    order by col1

    COL1 COL2 CNT_ALL CNT_NOT_NULL CNT_UNIQUE
    1 20 3 3 3
    2 20 3 3 3
    3 20 3 3 3

    Concerning

    Etbin

  • Copy the default value from another field in the same page

    Hello

    I need to pass a value from one page to another page and I want to use this key as DEFAULT VALUE for a field.

    If I create a form tabular all it's ok, but if I create a normal page. I am not able to do that.

    1. 1. I call the page and I pass the value. I also have a FIELD of VIEW and I can see the correct value.
    2. 2. I create a field with attributes of this:
      1. a. source > Source = database column type
      2. b. sources > Source value or expression = FK_ID_DA (the column name)
      3. c. default > default = P27_PK_ID_DA (the field that contains the value)
    3. 3. on the screen, I see P27_PK_ID_DA and not the value

    Where is the error?

    Thank you very much

    TexasApexDeveloper wrote:

    You missed one: before the variable, without it, the default value is the string...

    Not sure that you can READ the other pages... Such that if you are on Page 27 and have a field that you want to use on page 30, page 27 is presented and its items in session state, you can 'see' on page 30.

    So, if you set the default value: P27_PK_ID_DA, then you should get by default, you are looking for...

    Only if the default value Type is set on the PL/SQL Expression. If the literal value "P27_PK_ID_DA" is seen then the Type of default value should currently be set static text with Substitutions of State of Session, in which case the value of session state must be referenced using the syntax of substitution string:

    &P27_PK_ID_DA.

  • the row_number() value another column in the same table

    Hi all
    I have NODE_DETAILS which has following of table columns

    MSLINK
    NODE_ID
    RNUM

    I update RNUM with row_number() value in ordering the mslink. I tried after update statement

    Update)
    Select / * + bypass_ujvc * / rnum has, row_number() over (order of mslink) NODE_DETAILS rrnum
    )
    set a = rrnum

    But he throws ORA-01732: non-legal data manipulation operation on this display error

    How can I update row_number() rnum column?

    Thank you
    Sujnan

    You can use MERGE

    SQL> create table node_details
      2  (mslink number
      3  ,node_id number
      4  ,rnum number
      5  )
      6  /
    
    Table created.
    
    SQL>
    SQL> insert into node_details
      2  select -rownum, rownum, null
      3    from all_objects
      4   where rownum <= 5
      5  /
    
    5 rows created.
    
    SQL>
    SQL> select *
      2    from node_details
      3  ;
    
        MSLINK    NODE_ID       RNUM
    ---------- ---------- ----------
            -1          1
            -2          2
            -3          3
            -4          4
            -5          5
    
    SQL>
    SQL> merge into node_details n
      2  using (select rowid rid,rnum a, row_number() over (order by mslink) rrnum from NODE_DETAILS) v
      3  on (v.rid = n.rowid)
      4  when matched then
      5     update set rnum = rrnum
      6  ;
    
    5 rows merged.
    
    SQL>
    SQL> select *
      2    from node_details
      3  ;
    
        MSLINK    NODE_ID       RNUM
    ---------- ---------- ----------
            -1          1          5
            -2          2          4
            -3          3          3
            -4          4          2
            -5          5          1
    
    SQL>
    SQL> 
    
  • By comparing the values of the column within the same line

    Script

    < code >

    create table testp
    (name, varchar2 (20),)
    Yr1 number,
    number of YR2,
    number of YR3
    number of yr4);

    insert into testp values ('Jana', 900, 300, 400, 500);

    insert into testp values ("sarat", 200, 300, 800, 100);

    commit;

    < code >

    I need the result like this

    < code >

    NAME First_greatest Second_greatest

    Jana 900 500

    Sandrine 800 300

    < code >

    I used the larger function for the First_greatest result, but do not get the second_greatest, can you help me?

    Thank you

    Hello

    Here's a way to do it:

    WITH got_r_num AS

    (

    SELECT name

    ,        n

    ROW_NUMBER () (PARTITION BY NAME

    ORDER BY DESC n

    ) AS r_num

    OF testp

    UNPIVOT (n

    YEAR IN (yr1

    yr2

    an3

    yr4

    )

    )

    )

    SELECT *.

    OF got_r_num

    PIVOT (MAX (n)

    FOR r_num IN (1 AS first_greatest

    2 UNDER second_greatest

    )

    )

    ;

    Output:

    NAME FIRST_GREATEST SECOND_GREATEST

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

    Jana                            900             500

    Sandrine 800 300

    Maybe your data must be stored in a form upivoted in the first place, with each year on a separate line.

  • I have a column with two values, separated by a space, in each line. How to create 2 new columns with the first value in a column, and the second value in another column?

    I have a column with two values, separated by a space, in each line. How do I create 2 new columns with the first value in one column and the second value in another column?

    Add two new columns after than the original with space separated values column.

    Select cell B1 and type (or copy and paste it here) the formula:

    = IF (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    shortcut for this is:

    B1 = if (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')

    C1 = if (Len (a1) > 0, Member SUBSTITUTE (A1, B1 & "", ""), "")

    or

    the formula of the C1 could also be:

    = IF (Len (a1) > 0, RIGHT (A1, LEN (A1) −FIND ("", A1)), "")

    Select cells B1 and C1, copy

    Select cells B1 at the end of the C column, paste

  • By the way Select list value to another page via report link

    Hello

    I have a page 1001 with an item from the selection list (SLI), a button (BTN) and a report (EPR).

    After selecting a value of the element of selection it s possible to click on the button.

    After clicking the report button will display the data. Report structure: ID, COL1, COL2, COL3, COD values in COL1 is the links to the page 1011.

    I managed to pass the value of a column in the report, but how to pass the value of SLI this link?

    I tried: SLI, SLI, #SLI # and & SLI... but nothing has worked.

    You have an idea?

    1013248 wrote:

    Please update your forum profile with a real handle instead of '1013248 '.

    I have a page 1001 with an item from the selection list (SLI), a button (BTN) and a report (EPR).

    After selecting a value of the element of selection it s possible to click on the button.

    After clicking the report button will display the data. Report structure: ID, COL1, COL2, COL3, COD values in COL1 is the links to the page 1011.

    I managed to pass the value of a column in the report, but how to pass the value of SLI this link?

    I tried: SLI, SLI, #SLI # and & SLI... but nothing has worked.

    You have an idea?

    Use the exact static text substitution method to reference the value of the element. This requires an end point ('.) ») :

    &SLI.
    
  • Select the distinct value of a column in the collection in bulk.

    Hi all

    Collecting the data of a query to a variable of type table. I need to select a separate of a perticular column value in the collection.

    Collection has followiing values inside.
    Col(c).articleid,
    Col(c).userkey,
    Col(c).origin,
    Col(c).addnlorigindata,
    Col(c).avdest,
    Col(c).dispfmt,
    Col(c).sourcecode,
    Col(c).success_ind,
    Col(c).error_code,
    Col(c).entry_createddate,
    Col(c).createdby,
    Col(c).filenumber,
    Col(c).linenumber,
    Col(c).acctnum,
    Col(c).assetkey,
    Col(c).autocompletedterm,
    Col(c).accessionnumber,
    Col(c).requestdatetime,
    Col(c).requestorip,
    Col(c).articleordinal,
    Col(c).userinitiatedind,
    Col(c).captchastatus
    I need to select distinct column values (for example: Col (c) .sourcecode) collection and the need to insert in the table if the value in this column does not exist in the table.

    Say, Col (c) .sourcecode has the value XYZ, ABC. If the "XYZ" value does not exist in the table, so I need to insert in the table and if "ABC" exists in the tables then don't insert it. (something like fusion) after seecting to the distinct values in a column in the collection.

    Thanks n regards
    Nana Akkivalli.

    The collection must be inserted before you can use this topic.

    In the Begin block, you have to collect a loose and insert inside: something like

    SELECT *
    BULK COLLECT INTO l_array
    FROM ALL_USER
    ...CONDITIONS...
    
  • How to disable a page based on the value of another element on the Page element?

    Hello

    How can I turn a page element using javascript based on the value of another element on the page?

    Eg: P1_TEXT want to be disabled if the value in P1_LCOK = "LOCK".

    How can I do this using javascript. I want this implemt on loading the page.

    Kind regards
    Benz

    Put this function in the page header:

    
    

    and call it in the footer:

    f_disable_item;
    

    Denes Kubicek
    ------------------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    ------------------------------------------------------------------------------

  • How to take a column of duplicate names and fill a different column with the same names, excluding duplicates?

    How to take a column of duplicate names and fill a different column with the same names, excluding duplicates?

    I find easier to use this copy separate Automator Service (download Dropbox).

    To install in your numbers > Services, double-click menu just the package downloaded .workflow and if necessary give permissions in system preferences > security & privacy.

    To use, just:

    1. Select the cells in the column with duplicate names.
    2. Choose separate copy in numbers > Services menu.
    3. Click once in the upper cell where you want the deduplicated values appear.
    4. Command-v to paste.

    SG

  • place a select query calculation in a different column in the same table

    How can I put my calculation result in a column named within the same table?

    I have a table called: dgpercentagedatachart

    I use the columns of this dgpercentagedatachart: totalcecrating divided by lowestfeederrating times 100 to get the percentage

    In the query, I gave the result the Alias of the cal

    What I want is to put this result in my application or my calculation (in percentage) in my column "percent" on my table of dgpercentagedatachart vacuum.

    How can I configure this syntax?

    This is the select query, I came with:

    Select dgpercentagedatachart.totalcecrating, dgpercentagedatachart.lowestfeederrating,.

    100.00*dgpercentagedatachart.totalcecrating/dgpercentagedatachart.lowestfeederrating as cal

    of dgpercentagedatachart;

    Here are the results:

    CAL lowestfeederrating Totalcecrating

    8,978 7.48166666666666666666666666666666666667 120

    30.951 25.7925 120

    5.04                         120                          4.2

    Hello

    2685870 wrote:

    How can I put my calculation result in a column named within the same table?

    I have a table called: dgpercentagedatachart

    I use the columns of this dgpercentagedatachart: totalcecrating divided by lowestfeederrating times 100 to get the percentage

    In the query, I gave the result the Alias of the cal

    What I want is to put this result in my application or my calculation (in percentage) in my empty column '%' on my table of dgpercentagedatachart .

    How can I configure this syntax?

    This is the select query, I came with:

    Select dgpercentagedatachart.totalcecrating, dgpercentagedatachart.lowestfeederrating,.

    100.00*dgpercentagedatachart.totalcecrating/dgpercentagedatachart.lowestfeederrating as cal

    of dgpercentagedatachart;

    Here are the results:

    CAL lowestfeederrating Totalcecrating

    8,978 7.48166666666666666666666666666666666667 120

    30.951 25.7925 120

    5.04                         120                          4.2

    To change an existing column in a table, you can use the UPDATE or MERGE, instructions like this:

    UPDATE dgpercentagedatachart

    Percentage of VALUE = 100,00 * totalcecrating

    / lowestfeederrating

    ;

    Noramlly, tables is not redundant columns like this.  If percent can always be calculated from other columns, then it is probably better to calculate at run time and store it in the database, where you will have to be updated each time the columns it depends on change.  You can use a view to avoid having to encode them the calculation.

    If you really don't want a column that can be calculated in the same lines other columns, then use a virtual column (if you use Oracle 11 or higher).

    I hope that answers your question.

    If this isn't the case, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and also publish outcomes from these data.

    If you ask on a DML statement, such as UPDATE, the sample data will be the content of the or the tables before the DML, and the results will be the State of the or the tables changed when it's all over.

    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: Re: 2. How can I ask a question on the forums?

  • Add column if the value in another column

    How can I add a column as column name 'YES_OR_NO.

    SELECT VALUE_ID IN THE TABLE TABLE_NAME

    VALUE_ID
    ---
    1
    2
    3
    4
    5

    Now, I want to create another column in the sql query called YES_OR_NO and that if there is a value in VALUE_ID then column YES_OR_NO must say 'YES' if there is no value in the column VALUE_ID of this line YES_OR_NO must say 'NO '.

    or just a way for her also to work would be to show this new column or not if a value in another column of table_name_2 (this would be ideal)
    If new column yes_or_no and fill by a Yes or a no if a value is found in another table

    Assuming that you are on a version that supports the CASE expression:

    SELECT VALUE_ID
          , case when VALUE_ID is null then 'NO' else 'YES' end as YES_NO
    FROM TABLE_NAME
    
  • How to make an update of location to a group of photos at the same time?

    How to make an update of location to a group of photos at the same time?  This used to be a feature in iPhoto.

    I use El Capitan 10.11.6 and Photos 1.5

    If yu have OS X 10.5.1 s you say that you can not - with OS X 10.11.6 Photos 1.5 (a free update in the app store) you select them and info - enter the location and it will apply to all photos

    LN

  • Column sum based on a single value of another column

    Hi all

    I've searched and searched, but just can't find if this is even possible, let alone how to do it.  What I'm trying to do, it's the sum of a column.  However, only summarize the results of this column if a specific value of another column is present.  So, for example, the following is a sample database entry:

    Rate of pay hours

    2.3                                  $14.00

    1.2                                  $14.00

    2.4                                  $12.50

    0.75                                $12.50

    So for that, I want the sum of hours worked column but only the sum of hours worked if the wage rate is $14.00 and $ 12.50.  Because these numbers are generated in a database (with the various people who enter multiple rates of pay), I won't be able to set the where statement to have a specific amount (since I don't know the specific amount each registrant), the amount must be a variable in the where the statement.  With MySQLI, I know not how to make the sum of hours worked, but I do not know how the sum of hours worked if and only if the line corresponds to the unique value in the rate column.

    Then have it automatically loop through and total hours worked for other unique values in the column salary rate.  Finally, out all unique values in the column rate in variables so that I can do the following for each game:

    $total1 = $total_hours1 * $wage_rate1
    $total2 = $total_hours2 * $wage_rate2
    $overall_total = $total1 + $total2
    

    where $wage_rate1 = $14.00 and $total_hours1 = 2.3 + 1.2: etc.

    Is it still possible?  If so, how?  If possible, can someone please let me know a good reference so I can learn how to be the best way to implement?

    Thank you

    So with that, I get the correct $final_total printed, but I still get the error, 'notice: Undefined variable: final_total. Why is it not defined, but prints the total exact? How to remove the error?

    You get this notice is because you use the assignment combined, operator that is normally used to add a value to a variable and assign the new value to it.

    $final_total += $total;

    is a shortcut for this:

    $final_total = $final_total + $total;

    The undefined $final_total is on the right side of the assignment operator. The first time through the loop, you add $total to a non-existent value. Because of the type of PHP juggling, this becomes:

    $final_total = 0 + $total;

    The next time the loop runs, $final_total has a value, so that you get the view variable not defined only once.

    To avoid advice, initialize $final_total to zero before the start of the loop.

    $final_total = 0;

    While ($row = {$sql-> fetch_array())}

Maybe you are looking for