How to select a value of a max value of another column in the same row?

pversion pdate pcount
1     11/6/2011     1
0     11/6/2011     25
1     11/6/2011     24
How to select pversion for a maximum pcount, in this case max count is 25 and version will be 0?

Like this?
-- Data:
with yourtable as
select 1 pversion , 1 pcount from dual union all
select 0 , 25 from dual union all
select 1 , 24 from dual
-- Query:
select max(pversion ) keep (dense_rank last order by pcount) m_pversion
from yourtable;(When you want to use the query with your real data, you will have to change 'yourtable' to your actual tablename)

Similar Messages

  • How can I sum every other column in the same row?

    I have, for each employee, two columns: Planned and Worked.
    I would like to sum the values in each Planned column. There are 25 employees, each with their own Planned and Worked columns, on the same row.
    How can I do a SUM of every other column, starting with Planned?
    Thank you.

    Thank you, Yellowbox!
    The exact formula didn't work; however, it gave me a precise path to follow and come up with this: =SUMIF(E2:BB2,"=Planned",E3:BB3)
    Week
    Ending Date
    Planned Subtotal
    Worked Subtotal
    Employee1
    Employee2
    Employee3
    Planned
    Worked
    Planned
    Worked
    Planned
    Worked
    1
    01/04/2014
    120
    40
    38
    40
    44
    40
    50
    2
    01/11/2014
    If not for your starting point, I'd have wasted many more hours on this.
    Thanks again!
    BB

  • How do I move Contacts & Calendar from one User to another User on the same Macbook Pro?

    How do I move Contacts & Calendar from one User to another User on the same Macbook Pro? OSX 10.9.5

    is this second library in a different account on the computer?
    Look at Home Sharing.
    iTunes: How to share music and video - http://support.apple.com/kb/HT2688 - about Music Sharing and Home Sharing
    Home Sharing Support page - http://www.apple.com/support/homesharing/
    iTunes: Setting up Home Sharing on your computer - http://support.apple.com/kb/HT4620
    iTunes Home Sharing now works between users on same computer - https://discussions.apple.com/thread/3865597

  • Copying a Calculated Field Value to another Field in the same List

    Hello! I have a calculated field that uses an if statement to determine a score. IE A field called Downtime Score contains this calculate:  IF Downtime Minutes =10, 100.  (not correct formatting, just basic to get point across)
    I simply want to use a workflow to copy the calculated value in Downtime Score (100) to another field called Final Downtime Score.
    In the workflow, I current have the following:  Set FinalDowntimeScore to CurrentItem:Downtime Score
    When I log both to workflow history, they both show 0 in history.  Nothing is copying.
    The calculated field is a number and I tried both number and text fields for FinalDowntimeScore.
    This is within SharePoint 2013 and using SharePoint Designer 2013.
    Any help would be appreciated!

    Ok, I did the same test as you and it failed.  I still return a 0 when I should see a 100.
    Not sure if this helps but when even though we are using sharepoint designer 2013, we only have "SharePoint 2010 Workflow" available in Platform type when creating workflows.
    Could you test again using SharePoint 2010 workflow as your platform type and see if you return the same results?
    Thanks!

  • How to populate corresponding values in another columns

    product (table having below mentioned with data also)
    product_name product_code product_id lob_id product_desc
    DUMMY     DM     208182324072008     31     
    Fleet     FL     196870715012008     31     Fleet
    Commercial Vehicle CV     195147926122007     31     Commercial Vehicle
    Private Car     PC     194398713122007     31     Private Car
    Two Wheeler TW     194731914122007     31     Two Wheeler
    cause_of claim ( table below mention fields with data)
    cause_of_claim_id product_id cause_of_claim_code cause_of_claim_desc
    198035026022008     194398713122007     TP     Third Party
    198028726022008     194731914122007     TP     Third Party
    198065826022008     196870715012008     TP     Third Party
    198065726022008     196870715012008     OD     Own Damage
    198045226022008     195147926122007     OD     Own Damage
    198045326022008     195147926122007     TP     Third Party
    i have mentioned cause_of_claim data based on below query cause_of_claim_code having different type of values. currently we are focusing on "OD" and "TP" only. thats why i have reduced unnessary columns.
    select cause_of_claim_id,product_id,cause_of_claim_code,cause_of_claim_desc from cause_of_claim
    where cause_of_claim_code='OD' or cause_of_claim_code='TP'
    product and cause_of_claim we can join based on product_id.
    in product table product_desc having
    Two Wheeler
    Private Car
    Commercial Vehicle
    Fleet
    like that values...........
    requirement is
    where ever cause_of_claim_code ='OD' and
    product_desc in (Two Wheeler,
    Private Car,
    Commercial Vehicle,
    Fleet) need to populate one column dept_code and value should be value '31'
    where ever cause_of_claim_code ='TP' and
    product_desc in (Two Wheeler,
    Private Car,
    Fleet ) need to populate same column dept_code and value should be value '32'
    where ever cause_of_claim_code ='TP' and
    product_desc ='Commercial Vehicle'
    need to populate same column dept_code and value should be value '39'
    expected result
    product_desc dept_code
    Two Wheeler     31
    Private Car     32
    Two Wheeler     32
    Commercial Vehicle 31
    Fleet     32
    Fleet     31
    Private Car     32
    Commercial Vehicle 39
    Fleet     32
    Private Car     31

    This is school work. Please do the best you can then post it along with information about your version number (3 decimal places) and the issue you are experiencing with your code.
    Please everyone ... I know you want to demonstrate your skill ... but students need to work these things out for themselves or they do not learn.

  • How to retrieve hashmap Values in other class within the same package.

    I have created two class ie A and B.
    In A class I have created one hashmap and stored some keys and values.
    But i want to retrieve that values in class B.
    So can any one can give any code ,so that i will try on Eclipse IDE

    Maybe anything. I'm not that interested. It's Java programming 101, about 10 minutes into the first class.

  • How to calculate totals based on year (date) and comparing othe columns in the same table please

    Hello Good Evening,
    Could you please help me here
    how to write condition for self table year records, such 2012 name and acctno match with 2013 name and acctno then total, provided below,
    create table #tab1 (MasterKey int, AcctNo varchar(12),name varchar(25), SumaofShares numeric, request_dat datetime )
    --drop table #tab1
    insert into #tab1 values (1000, 100,'Tom', 2500, '10/01/2012')
    insert into #tab1 values (1001, 101,'Bat', 1550, '08/11/2012')
    insert into #tab1 values (1002, 102,'Kit', 1600, '06/12/2012')
    insert into #tab1 values (1003, 103,'Vat', 1750, '04/15/2012')
    insert into #tab1 values (1010, 104,'Sim',200, '04/21/2013')
    insert into #tab1 values (1011, 105,'Tim',500, '06/18/2013')
    insert into #tab1 values (1012, 100,'Tom',800, '08/22/2013')
    insert into #tab1 values (1013, 101,'Bat',550, '09/15/2013')
    insert into #tab1 values (1014, 100,'Pet',200, '02/21/2013')
    insert into #tab1 values (1015, 103,'Vat',150, '03/18/2013')
    insert into #tab1 values (1016, 110,'Sun',800, '03/22/2013')
    insert into #tab1 values (1017, 111,'Bet',550, '12/15/2013')
    insert into #tab1 values (9999, 111,'AAA',110, '12/15/2014')
    create table #tab2 (IssueKey int, totalOutstanding numeric, sharedBenefits varchar(1) )
    --drop table #tab2
    insert into #tab1 values (1000, 500, 'V')
    insert into #tab1 values (1001, 150, 'U')
    insert into #tab1 values (1002, 100, 'N')
    insert into #tab1 values (1003, 170, 'U')
    insert into #tab1 values (1010, 100, 'U')
    insert into #tab1 values (1011, 200, 'K')
    insert into #tab1 values (1012, 340, 'U')
    insert into #tab1 values (1013, 560, 'N')
    insert into #tab1 values (1014, 280, 'V')
    insert into #tab1 values (1015, 150, 'V')
    insert into #tab1 values (1016, 840, 'V')
    insert into #tab1 values (1017, 530, 'N')
    i would like to get 4 columns output
    how to get sumofshares (#tab1) and TotalOutStanding(#tab2) summ up with these values please.,
    MasterKey (#tab1) and IssueKey (#tab2) are like primary key and foreign key
    so the request is
    need to calculate, sumofshares (#tab1) and TotalOutStanding(#tab2) as below
    1)ShareBenefist = U and year( request_dat) in (2012 , 2103) and (Name for 2012 should match with 2013 name and 2012 Acctno should match with 2013 accounno) in (#tab1)
    then '2012 and 2013 accts UN Veriverted'
    2)ShareBenefist = V and year( request_dat) in (2012 , 2103) and (Name for 2012 should match with 2013 name and 2012 Acctno should match with 2013 accounno) in (#tab1)
    then '2012 and 2013 accts Veriverted'
    3)ShareBenefist = N and year( request_dat) in (2012 , 2103) and (Name for 2012 should match with 2013 name and 2012 Acctno should match with 2013 accounno) in (#tab1)
    then '2012 and 2013 accts NONVERT'
    4)year( request_dat) =2102 and Name and Acctno not match with 2013 account name and acctno (#tab1)
    then '2012 last year accounts'
    5)year( request_dat) = 2013 and Name and Acctno not match with 2013 account name and acctno (#tab1)
    then '2012 This year accounts'
    for ex 1) the below accounts in #tab1 has both 2012 and 2013 and acctno same in both years and name is same in both years so it is condired as
    insert into #tab1 values (1012, 100,'Tom',800, '08/22/2013')
    for ex 2)
    insert into #tab1 values (1013, 101,'Bat',550, '09/15/2013')
    for ex 4) 2012 records there is not match acctno and name in 2013 recods
    insert into #tab1 values (1002, 102,'Kit', 1600, '06/12/2012')
    for ex 5) 2013 records there is no match of name and acct no with 2012 records
    insert into #tab1 values (1010, 104,'Sim',200, '04/21/2013')
    insert into #tab1 values (1014, 100,'Pet',200, '02/21/2013')
    insert into #tab1 values (1016, 110,'Sun',800, '03/22/2013')
    insert into #tab1 values (1017, 111,'Bet',550, '12/15/2013')
    Expected Results (just for format)
    AcctTypeDescription, SumofShares, OtotalutStand
    '2012 and 2013 accts UN Veriverted',2700,234
    '2012 and 2013 accts Veriverted' ,2890,234
    '2012 and 2013 accts NONVERT' ,4533,325
    '2012 last year accounts' ,2334,567
    '2012 This year accounts' ,2222,877
    Please
    Thank youy in advance
    asita

    As I understand it, your sample output was only to show the format, and did not pretend to be give the exact result given the sample data. This is pity, because means that I was not able to verify that my query below gives the desired result.
    The exact relation between #tab1 and #tab2 is not clear to me. I'm making the assumption that a row in #tab1 may have zero or one row in #tab2, but not many.
    My solution has two CTEs. The first simply joins the tables together and extracts the year. In the second CTE, I perform a self-join over the first CTE which I have divided in two by year. This is a full join, since an account may appear for only one of
    the year. Note that it is instrumental to extract the year data in inner queries first.
    The final query is just an aggregation over the categories.
    create table #tab1 (MasterKey int, AcctNo varchar(12),name varchar(25), SumaofShares numeric, request_dat datetime )
    --drop table #tab1
    insert into #tab1 values (1000, 100,'Tom', 2500, '10/01/2012')
    insert into #tab1 values (1001, 101,'Bat', 1550, '08/11/2012')
    insert into #tab1 values (1002, 102,'Kit', 1600, '06/12/2012')
    insert into #tab1 values (1003, 103,'Vat', 1750, '04/15/2012')
    insert into #tab1 values (1010, 104,'Sim',200, '04/21/2013')
    insert into #tab1 values (1011, 105,'Tim',500, '06/18/2013')
    insert into #tab1 values (1012, 100,'Tom',800, '08/22/2013')
    insert into #tab1 values (1013, 101,'Bat',550, '09/15/2013')
    insert into #tab1 values (1014, 100,'Pet',200, '02/21/2013')
    insert into #tab1 values (1015, 103,'Vat',150, '03/18/2013')
    insert into #tab1 values (1016, 110,'Sun',800, '03/22/2013')
    insert into #tab1 values (1017, 111,'Bet',550, '12/15/2013')
    insert into #tab1 values (9999, 111,'AAA',110, '12/15/2014')
    create table #tab2 (IssueKey int, totalOutstanding numeric, sharedBenefits varchar(1)  )
    --drop table #tab2
    insert into #tab2 values (1000,  500,  'V')
    insert into #tab2 values (1001,  150,  'U')
    insert into #tab2 values (1002,  100,  'N')
    insert into #tab2 values (1003,  170,  'U')
    insert into #tab2 values (1010,  100,  'U')
    insert into #tab2 values (1011,  200,  'K')
    insert into #tab2 values (1012,  340,  'U')
    insert into #tab2 values (1013,  560,  'N')
    insert into #tab2 values (1014,  280,  'V')
    insert into #tab2 values (1015,  150,  'V')
    insert into #tab2 values (1016,  840,  'V')
    insert into #tab2 values (1017,  530,  'N')
    go
    WITH joined AS (
      SELECT a.MasterKey, a.AcctNo, a.name, a.SumaofShares,
             year(a.request_dat) AS year, b.totalOutstanding, b.sharedBenefits
      FROM   #tab1 a
      LEFT   JOIN #tab2 b ON a.MasterKey = b.IssueKey
    ), categories (category, sumofshares, totaloutstanding) AS (
       SELECT CASE WHEN A.MasterKey IS NOT NULL AND
                        B.MasterKey IS NOT NULL
                        THEN '2012 and 2013 accts ' +
                             CASE B.sharedBenefits
                                WHEN 'U' THEN 'UN Veriverted'
                                WHEN 'V' THEN 'Veriverted'
                                WHEN 'N' THEN 'NONVERTED'
                                ELSE ''
                             END
                   WHEN A.MasterKey IS NOT NULL THEN '2012 last year accounts'
                   WHEN B.MasterKey IS NOT NULL THEN '2013 this year accounts'
              END,
              coalesce(A.SumaofShares, 0) + coalesce(B.SumaofShares, 0),
              coalesce(A.totalOutstanding, 0) + coalesce(B.totalOutstanding, 0)
       FROM   (SELECT * FROM joined WHERE year = 2012) AS A
       FULL   JOIN (SELECT * FROM joined WHERE year = 2013) AS B
             ON A.AcctNo = B.AcctNo
            AND A.name   = B.name
    SELECT category, SUM(sumofshares) AS sumofshares,
           SUM(totaloutstanding) AS totaloutstanding
    FROM   categories
    GROUP  BY category
    go
    drop table #tab1, #tab2
    Erland Sommarskog, SQL Server MVP, [email protected]

  • UIX: How to display more items in 1 column on the same row

    Hi
    I have a uix table with a couple of columns.
    Now I want to display more elements in 1 column, but on the same row
    E.g.
    article | quantity <> | price
    The quantity column has also to buttons to increase/decrease the quantity. Something like:
    <column>
    <columnFormat displayGrid="true" cellNoWrapFormat="true" columnDataFormat="numberFormat"/>
    <columnHeader>
    <sortableHeader text="Quantity" required="yes"/>
    </columnHeader>
    <contents>
    <messageTextInput id="${ui:concat('PurchaseInvoiceLinesView3:Quantity:',uix.current.tableIndex)}" model="${ui:cond(uix.current.isNewRow,null,uix.current.PurchaseInvoiceLinesQuantity)}" text="${uix.current.PurchaseInvoiceLinesQuantity}" name="Quantity" promptAndAccessKey="Quantity" rows="1" maximumLength="6" columns="8">
    <onSubmitValidater>
    <decimal/>
    </onSubmitValidater>
    </messageTextInput>
    <button text="&lt;" onClick="..."/>
    <button text="&gt;" onClick="..."/>
    </contents>
    </column>
    But both buttons appear on a new line. Resulting in:
    [   1]
    <
    >
    The useSeperateRows attribute is by default false, so that should be ok. Any ideas to get the buttons on the same row?
    Regards.

    Hi,
         If all of your line items are getting displayed in different pages, to my knowledge, there may be two possibilities.
    1) May be the size of the main window can accomodate only one line item. If one item data fills up the window, then there wont' be any space for the next line item data to be accomodated in the same window in the same page, so, the system triggers the next page. Like-wise for each item data. If this is the case, increase the height of the main window to display items in same page.
    2) Check the driver program. Find the Write_form block, which is written inside an item loop. May be there is a Form-control Function module( Control_form with parameter 'NEW-PAGE' ) being called after the write_fom block, within the loop. If this is the case, remove the control_form FM section to make the data display in same page.
    Best Regards,
    Kumaar.S

  • Summing Selected Rows in Column Depending on Value in Another Column

    I'd like to sum only the values in selected rows in a given column depending on the value of another column in the same row. For example, suppose I have a table (please disregard the underscores, needed for correct alignment):
    ___A____B____C___D
    1__5___10___15___0
    2_20___25___30___1
    3_35___40___45___1
    4_50___55___60___0
    5__sum(D=1)
    In cell B5, I'd like to compute the sum of only rows in column B for which the value of the corresponding column D is 1. In this case B5 would be 65.
    How can I do this using functions? Is it possible to do it for a variable range of rows without specifying each row individually?
    Thanks,
    Dave

    You should place your formula to other collumn then calculated ones or in another table. You will be able to calculate whole collumns with: =SUMIF(D;“=1”;B)
    Formula for your example is: =SUMIF(D1:D4;“=1”;B1:B4)
    VB

  • Update one column while getting the value in another column

    Is it possible to in one single SQL statement update two columns in a table while at the same time obtaining the value of another column, on the same row, in the same table, and independently (that is, the update of the columns has nothing to do with the data that I want from another column)*?* Of course, I can do this in two operations, one being a "select" and the other one being an "update", but since I am in the same table and even on the same row, is it really necessary to make TWO database calls? That's why I want to combine the the two SQL-statements, for reasons of presumed effiency.

    jsun wrote:
    Is it possible to in one single SQL statement update two columns in a table while at the same time obtaining the value of another column, on the same row, in the same table, and independently (that is, the update of the columns has nothing to do with the data that I want from another column)*?* Of course, I can do this in two operations, one being a "select" and the other one being an "update", but since I am in the same table and even on the same row, is it really necessary to make TWO database calls? That's why I want to combine the the two SQL-statements, for reasons of presumed effiency.Two statements != two database calls.
    At least not in terms of SQL.
    JDBC requires a 'statement' but in SQL (depending on the data source) that can include multiple statements. An obvious example of this is a stored proc but there are other ways as well.

  • Need to get sequence value in another column in oracle

    Hi ALL,
    I have sql query as below
    select header_id,order_number from oe_order_headers_all.
    and data it is displaying as
    heder_id     order_number
    111            500001
    121            500400
    I need to display  another field with some sequence value like as below
    id     heder_id     order_number
    1      111                    500001
    2      121                    500400
    so how to get sequence value in another column please help me on this.
    Thnaks

    You can just use ROWNUM Pseudocolumn
    select rownum id, header_id,order_number from oe_order_headers_all

  • Insert value into a column based on value of another column

    Hi,
    I am trying to insert a value into a record based on a column in
    the record, using a trigger. The complication arises because
    the new value is selected from the same table. For example:
    SELECT COL1, COL2, COL3, COL4 from TABLE1
    I want to set COL2 and COL3 based on the value of COL4. And to
    get the value of COL2 and COL3, I will go back to TABLE1 and set
    the condition to TABLE1.COL1 = :NEW.COL4
    I cannot seem to execute the trigger as I get the message "ORA-
    04091: table SYSTEM.TABLE1 is mutating, trigger/function may not
    see it" everytime.
    Is this the correct way to achieve what I wanted? Or is there
    another way?
    Appreciate your feedback. Thank you in advance.

    Hi,
    I am trying to insert a value into a record based on a column in
    the record, using a trigger. The complication arises because
    the new value is selected from the same table. For example:
    SELECT COL1, COL2, COL3, COL4 from TABLE1
    I want to set COL2 and COL3 based on the value of COL4. And to
    get the value of COL2 and COL3, I will go back to TABLE1 and set
    the condition to TABLE1.COL1 = :NEW.COL4
    I cannot seem to execute the trigger as I get the message "ORA-
    04091: table SYSTEM.TABLE1 is mutating, trigger/function may not
    see it" everytime.
    Is this the correct way to achieve what I wanted? Or is there
    another way?
    Appreciate your feedback. Thank you in advance. I'm not sure what you mean when you insert a value into a
    record, but if you are setting a value in a column of the same
    record using a trigger, then it's easy.
    :new.COL2 := ....:new.COL4...
    :new.COL3 := ....:new.COL4...
    The trigger must be 'INSERT or UPDATE' and 'FOR EACH RECORD'.
    If you are setting a different record in the same table, the
    solution is much more difficult.

  • How To select maximum Value in a specifieid field in internal table.

    How To select maximum Value in a specifieid field in internal table?

    Step : 1
    Sort itab by <Field1> descending.
    Just sort the internal table by the field.
    STEP: 2
    Then read the table at index 1.
    Read table itab index 1.               
    ITAB-FIELD = MAX .                  " Max field will come in the first row of the internal table.
    Regards,
    Gurpreet

  • How to select multiple values from a listbox

    Hi,
    I have a list box on my UI which is not allowing me to select multiple values
    I want to use multi select list box .. When i go to source of UI component and change that to select many listbox my page is not rendering it is giving error
    When i drag & drop the component i am unable to drop it as a multi select list box that option is not coming.
    I am working on Jdev 11.1.1.3 and I am using ADF/BC components
    How to select multiple values from a listbox ?
    Thanks,

    Hi,
    I want to use multi select list box .. When i go to source of UI component and change that to select many listbox my page is not rendering it is giving errorank
    And what is the error ?
    Frank

  • How to select multiple values from the parameters in BI Publisher report

    How to select multiple values from the parameter drop down in BI Publisher, and how to handle this mulitple values from the report sql...

    Hi kishore,
    I have used all the steps as you mentioned in your previous reply....including checking Mulitple Selection Check Box..
    Iam able to get the results when I am selecting one value..
    and also I am able to handle multiple values the in the query by using IN :Parameter, but seems when we select more than one value from the parameter drop down i think the Bi Publisher is sending the values in concatenated form something ilke
    ex: "'ACCOUNT','HR','SALES'" ,and when trying to display the parameters values in the output, its throwing the error as 'missing right paranthesis' ....on the whole do you have any solution which would handle
    1.Single selection.
    2.Multiple selection.
    3.'ALL' Values.
    4.Separating the concatenated string into individual strings and dispaly them on the output of the report..etc..in case of Mulitple selection.
    Ex:
    Concatenated String from BI Publisher:"'ACCOUNT','HR','SALES'"
    Expected Output on the report:ACCOUNT,HR,SALES
    reply to this would be much appreciated....
    thanks,
    manoj

Maybe you are looking for

  • I cannot install itunes 10.5.1 on windows XP.

    It gets about 3/4 way through installing then says there has been an error try downloading manually, which i do and the same error message appears. I have been trying to get this downloaded for ages now, and have trawlled through these discussion thr

  • BOM-Structure in service notification

    Dear Fnds, I have some BOM iwith usage 4 and 3...i have deliverd the Product to Customer. now it came for service ...i have ented in Service notification.....If user wants to see the Bill of material by Clicking Object info...and by clicking hierachy

  • Process flows objects in a database schema

    Hi, I want to find in a database schema the objects created by the Oracle Workflow. Is it possible? For example, when I create and deploy a mapping in OWB, a package is created in the target schema. I can handle it using only SQL. When I create a pac

  • How to open up Word files in Vista?

    Just bought my new laptop with Vista already installed. Set up was good and loaded up security. Checked my emails but could not open up a simple Word attachment. Can anyone help? It would be greatly appreciated. Thanks, Jay Cee, "Keep The Faith"

  • Work center capacity header freezed

    Dear Gurus, we're  not able to edit the work center capacity header. not able to edit the start and finish times. it is happening only for one work center. in other work centers same capacity category is editable. Please help us in resolving this. Re