Select querry for maximum value

Hi,
I want to select fields A B C D from a database table TAB using some selection criteria from selection screen, but the greatest value of A has to be selected for all unique entries of B C and D. Please suggest an appropriate select querry.
PS: I cannot use SELECT and then DELETE ADJACENT DUPLICATES as it will effect performance in some cases.
Regards.

Try using aggregate function MAX with SELECT statement.
MAX Returns the greatest value in the column determined by the database field f for the selected lines. Specifying DISTINCT does not change the result. NULL values are ignored unless all values in a column are NULL values. In this case, the result is NULL .
Have a look at below link:
[Select Clause|http://www.sts.tu-harburg.de/teaching/sap_r3/ABAP4/select_c.htm]
I hope it helps.
Best Regards,
Vibha
Please mark all the helpful answers

Similar Messages

  • Select statement for summing values in column?

    How to write a select statement for sap standard table which contains data  as given below
    col1        col2
    A     10
    A     20
    A     30
    B     50
    B     60
    C     70
    Need the output of select in  internal table as given below
    A     60
    B     110
    C     70
    Regards,
    Rachel

    Thanks for all the valuable input.
    Below I have used sum in select statement(check case 2"),but i am not getting required o/p.
    Kindly guide me.
    case1 :
    select aebeln aebelp bpackno  bmenge
    into corresponding fields of table itab
    from ( eslh as a inner join esll as b
    on bpackno = apackno )
    where a~ebeln = 6000000100
    and a~ebelp = 00010
    and a~packno = '0000001025'
    order  by aebeln aebelp b~packno .
    O/p for the above .
    ebeln                       ebelp         packno                             menge
    6000000100     00010     0000001025              6.000
    6000000100     00010     0000001025               5.000
    6000000100     00010     0000001025              2.000
    6000000100     00010     0000001025              1.000
    6000000100     00010     0000001025              2.000
    case2:
    select aebeln aebelp bpackno  sum( bmenge )
    into corresponding fields of table itab
    from ( eslh as a inner join esll as b
    on bpackno = apackno )
    where a~ebeln = 6000000100
    and a~ebelp = 00010
    and a~packno = '0000001025'
    group by aebeln aebelp b~packno
    order  by aebeln aebelp b~packno .
    6000000100     00010     0000001025     0.000
    Edited by: Rachel on Nov 25, 2008 11:45 AM
    Edited by: Rachel on Nov 25, 2008 11:46 AM

  • Select querry for hr records.

    hi all,
    i was writing a hr report to to get the employee no's based on the employment status given in the selection screen. i was using the standard screen  from PNP databse.
    but when i was giving the from and to date and the employment status . and i am using GET PERNR  to fetch the records. but it is not considering the status.
    so i wrote a select querry to check the records fetched after  GET PERNR matches with the employment status given in the selection screen. but the select querry is not working.
    SELECT SINGLE STAT2 INTO PERNR-STAT2 FROM PA0000
             WHERE PERNR = PERNR-PERNR
             AND   BEGDA GE PN-BEGDA
             AND   ENDDA LE PN-ENDDA
             AND   STAT2 IN PNPSTAT2.
          CHECK PERNR-STAT2 IN PNPSTAT2.
           IF SY-SUBRC NE 0.
             REJECT.
           ENDIF.
    so please some one give the select querry to get the records from pa0000 tables based on the date range given and the employment status given.

    Hi Praveen,
    welcome to SDN.
    Please check that did you pass
    <b>Infotypes: 0000.</b>
    in the declaration part of the statement.
    Get Pernr will consider the status then.
    Regards,
    Amit
    P.S. Please close the issue and reward points to helpful answer once Query is solved.
    Message was edited by: Amit Khare

  • Data selection slow for dimension value empty

    Dear BW Experts,
      I have face the below situation:
        Let say i have dimension A {Date_billing, Date_invoice, Date_reconcilation}, and I have dimension B {Sales Org, Distribution channel}
       Date_billing is always not empty because it is coming from billing document.
       But Date_invoice and Date_reconciliation is sometimes value are empty because those are calculated base on some logic.
      When i run querry with selection screen of {Date_billing, Sales org, Distribution Channel}, it runs very fast, it uses star stransformation.
      But when i run querry with selection screen of {Date_invoice, Sales org,..}, sometimes it runs very slow and even give dump due to run time long. I have checked and what i found is "If user enters the Date_invoice which is existing in dimension table, then it return value very fast, but if users enters some value of Date_invoice which is not existing in dimension table then i run ver slow and give dump".
      To advoid this situation, i have been thinking about NON_STAR_TRANSFORMATION, it is OK. But except this do we have any other solutions, do i missed somthing in my setting.
      I have been thinking that I should change selection screen like the way that only date existing in dimension table of Date_invoice will display, but I do not want to do this, what i refer is "Is there any other solutions related to BW selection setting to eliminate those such empty value fastly when inner join happens."
    I am looking forward to hearing from you.
    Thanks and regards,
    KIMC.

    Hi BW experts,
       i have checked, the reason is that they use STAR TRANSFORMATION, and we used oracle 10.2.0.2, I really do not know how to calculation cost of querry base on CBO.
       Please guy me, for example, i have a querry, how do i know cost of CBO run if that is STAR TRANSFORMATION and if that is NON STAR TRANSFORMATION.
       I am looking forwards to hearing from you.
    thanks and Regards,
    KIMC>

  • How can I switch to Longtext in a variable selection box for entered value

    I execute a Web Template and enter a value for example a company variable. After this I press the "Check"-Button and get the short text of the company but I want to see the long text.
    The InfoObject settings under Business Explorer is:
    Display:                                          Text
    Text Type:                                       Default
    BEx Description:                              Long description
    Selection:                                        No Selection Restriction
    Query Def. Filter Value Selection:      Values in Master Data Table
    Query Execution Filter Val. Selectn:  Values in Master Data Table
    Filter Value Rep. At Query Exec.:      Selector Box Without Values
    The InfoObject is a reference characteristic and the query was created on BEx 3.5.

    I changed the text type to long text, but the result is the same.
    The only way to get the desired result is to delete the short text and the middle text in the InfoObjects Text Table Properties. But this is not right way.

  • Querying many tables at once from a select statement for specific values

    Hi all,
    I'm very new to PL/SQL and have a daunting task ahead of me. I'm pretty sure our database normalization scheme is all out of whack, which I dont have the experience to fix yet, but this is the task ahead of me without getting to change or fix our structure:
    in the universe has 1000+ tables.
    need--> Some of those tables have fields that contain a value that has to be changed.
    The only thing I have to go on is the column name will contain 'EMP'... but there is no specific naming convention for the column names.
    When I search on:
    select * from all_tab_columns where column_name like UPPER('%EMP%')
    It returns 750 rows. (So 750 rows = 750 columns in 500 different tables (some tables have 2 or more columns in it))
    tables names are random (table1, table2, etc).
    columns names are random with EMP in it (column1,column2,etc).
    I have 75 possible field values that I need to check each of those 750 columns for.
    Maybe this is too messy, but I'm looking at subqueries, joins, arrays, cursors, etc, anything to minimize the amount of work I have to do.
    I think this is too much to do a join with, but that seems to be what all the documentation is pointing me to.
    can you point me to a simple example of what i could
    write?
    the logic i see it would be
    run the select statement to grab the column names that meet EMP.
    one at a time, search each column in the corresponding table for the 75 values.
    return the results of rows for each column/table that meet one of the 75 unique values.
    I'll have to also update each of the 75 values to (used to be values 1, 2, 3 ... to new values X1, X2, X3, etc.)
    Any help at all would be very helpful,
    aspiring pl/sql programmer but having a rough time of it

    I think you're looking to do something like the following pseudocode:
    BEGIN
        FOR tblrec IN (SELECT table_name, column_name
                         FROM all_tab_columns
                        WHERE column_name LIKE '%EMP%')
        LOOP
            FOR rec IN (SELECT ROWID
                          FROM tblrec.table_name
                         WHERE REGEXP_LIKE(tblrec.column_name, '(expr1|expr2|...)')
            LOOP
                DBMS_OUTPUT.PUT_LINE(
                    'Found expression on ROWID ' || rec.rowid
                    || ' in column ' || tblrec.column_name
                    || ' on table ' || tblrec.table_name);
            END LOOP;
        END LOOP;
    END;

  • EX lot size for maximum value

    Hi Could someone answer this, my minimum lot size is 100 and max is 500, when my PIR qty is 90 it will generate planned order for 100 where as when my PIR is 600, i am expecting the planned order qty for 500 but it always the same with minimum lot size, is there any specific reason? using mrp type PD.

    Hi Sprint,
    Well you have to go through with the lot size procedures OK. EX means lot for lot order quantity so it does not consider the MINIMUM lot size OK please check once again OK.
    If you are order quantity is 600 and maximum lot size is 500 then after running the MRP go to MD04 screen you can see there planned orders will be created so there first it will create Planned order for 500 quantity and then there will be another planned order for 100 please check once OK.
    It will consider only maximum lot size OK.
    Regards,
    Madhu.G

  • Error msg, "Maximum selection does not contain value 9999999999.

    Hi, I am getting this error wile doing Reclassification of HFM Movement.
    Error msg, "Maximum selection does not contain value 9999999999 of subassignment HFM CD2 & Asset Type "                                         
    in the Data Monitor, ( in Reclass Net Reserve). While running BCF task for a company for period 16/2009     
    Actually, We have converted the consolidation area from XX(2009) to YY(2010).
    Before this task, user has performed the balance carry forward.
    My Analysis is as follows:-
    Method Used in this Reclassification                                         
    RECYX (Reclassify HFM Movement at YE lvl 10)                                        
         TRIGGER                                   
         Items : 100-299, 9900-9999                                   
         HFM Movement Type : O200 to O300                                   
         Posting Level : 10                                   
         TARGET                                   
         Items : 100-299, 9900-9999                                   
         Move : O100C                                   
         Posting Level : 10                                   
         HFM CD2 and Asset type : Ticked                                    
    After TEST run in UCMON, the error message comes :-                                        
    The "HFM CD2 & Asset Type value 9999999999" is not maintained in Breakdown Categories Y500, Y700  etc.                                        
    Breakdown categories in Workbench                                        
    Maintained as "OPTIONAL, Initialized value allowed".                                        
    Single Selection                                         
    1A                                        
    1B                                        
    AR                                        
    GA                                        
    Default Selection                                        
    99999999999                                        
    BCS CUBE                                         
    HFM CD2 & Asset Type - coming blank               
    LOTR                                        
    HFM CD2 & Asset Type - Coming blank     
    Please help to go forward.
    In Anticipation,
    Deepankar Jain

    Thanks a lot Dan for the reply.
    Yes, the single selection is 1A, 1B etc, I agree that including this default value 9999999999 in single selection will resolve this issue, but the BREAK DOWN TYPE is OPTIONAL, that means It will also consider a blank value, right?
    Also, In the method defined for RECLASSIFICATION in workbench, in the TARGET parameters, the" HFM CD2 and Asset Type"  is blank but the "DEFAULT is TICKED" which makes it a mandatory derivation rule.
    Please correct me if I am wrong.
    Your replies on it are highly appreciated.
    Thanks and Regards,
    Deepankar

  • Maximum selection does not contain value 600 of subassignment Subitem-error

    Hi All,
    I'm getting the following error when i tried to load the file through data stream.
    Maximum selection does not contain value 600 of subassignment Subitem
    Message no. UCD1038
    Diagnosis
    The posting item 11100100 has breakdown category BR01 for which a maximum selection was maintained for subassignment Subitem. The current posting value, however, is not in this maximum selection.
    System Response
    The posting is not possible.
    Procedure
    Check the maximum selection and the posting.
    I have already refered the earlier threads but its of no use for me. I have checked my setting w.r.t to FS item breakdown category, Max selection in breakdown category and  sub items all the setting are fine, even i applied the OSS notes no-1074599 still i'm facing the same issue.
    Can any one help me with this regards, thanks in advance.
    Regards,
    Magesh

    Hi Dan,
    Yes, breakdown category has been assigned with a sub item category which in turn assigned to subitems and this sub item is a part of the sub item category which is assigned in max. selection.
    Let me know if you want any more information on the same.
    Regards,
    Magesh

  • "MAXIMUM NO OF HITS" field in selection screen for Product Search

    Hi all,
       We are  running on SRM 4.0.I have a query regarding the Selection screen which appears for the Product Search when we click on the "inetrnal Goods/Servcies" link...
        I have developed a Z-serch help for the Product search wherein i have control of  all the other fields lik "Product ID"," Product description " etc..But not "Maximum no of hits" (since it is  a part of the std functionality)...In the selection sceen field " Maximum  no of hits" ,whatever value i enter  that value is not considered...So is there any way that this field is not diplayed on screen/can be disabled(made an O/p field)...
      All suggestions are  welcome....Please  help...
    Thanks & Regards,
    Disha.

    Well,
    You're talking about COLLECTIVE search help. You won't definie Max No of hit at this level.
    Define an elementary search help and assign to this one a dialog mode (retriction or set of values).
    Regards,
    Bertrand
    PS : Don't forget reward points

  • Select-options in Selection Screen to show more rows for entering values

    Hi all,
    In my webdynpro abap  I have added the SELECT-OPTIONS componenet and working fine.
    User need  in the Selection Screen for select options  more rows to show entering values in single time.
    THe Default Rows show only 5 .
    user need to change to 10 or 15 Rows to show.
    Pl help .
    THanks in advance.
    Dev

    Hi,
    Here is the way which I just tested and found working.
    This is the main code which needs to be written.
    TYPES:
        ty_r_vbeln TYPE RANGE OF vbeln,
        ty_s_vbeln TYPE LINE OF ty_r_vbeln.
    data ls_vbeln type ty_s_vbeln.
    field-symbols <fs_range> TYPE INDEX TABLE.
    ASSIGN lt_range->* TO <fs_range>.
    do 10 times.
    APPEND ls_vbeln TO <fs_range>.
    enddo.
    For further refinement, you can create a input field in view for number of lines to be shown as enabled.
    The complete code is as below.
    DATA lo_cmp_usage TYPE REF TO if_wd_component_usage.
    lo_cmp_usage =   wd_this->wd_cpuse_select_options( ).
    IF lo_cmp_usage->has_active_component( ) IS INITIAL.
      lo_cmp_usage->create_component( ).
    ENDIF.
    DATA lo_interfacecontroller TYPE REF TO iwci_wdr_select_options .
    lo_interfacecontroller =   wd_this->wd_cpifc_select_options( ).
    DATA lo_r_helper_class TYPE REF TO if_wd_select_options.
    lo_r_helper_class = lo_interfacecontroller->init_selection_screen(  ).
    Creating range table
    DATA lt_range TYPE REF TO data.
    CALL METHOD lo_r_helper_class->create_range_table
        EXPORTING
          i_typename     = 'VBELN'
        RECEIVING
          rt_range_table = lt_range.
    Disabling the global options
    CALL METHOD lo_r_helper_class->set_global_options
      EXPORTING
          i_display_btn_cancel  = abap_false
          i_display_btn_check   = abap_false
          i_display_btn_reset   = abap_false
          i_display_btn_execute = abap_true.
           TYPES:
        ty_r_vbeln TYPE RANGE OF vbeln,
        ty_s_vbeln TYPE LINE OF ty_r_vbeln.
    data ls_vbeln type ty_s_vbeln.
    field-symbols <fs_range> TYPE INDEX TABLE.
    ASSIGN lt_range->* TO <fs_range>.
    do 10 times.
    APPEND ls_vbeln TO <fs_range>.
    enddo.
    Adding the selection field
    CALL METHOD lo_r_helper_class->add_selection_field
        EXPORTING
          i_id                         = 'VBELN'
          I_OBLIGATORY                 = ABAP_TRUE
          I_NO_EXTENSION               = abap_false
          i_value_help_type = if_wd_value_help_handler=>CO_PREFIX_SEARCHHELP
          it_result                    = lt_range.
    Edited by: Jayanthi Jayaraman on Dec 2, 2010 8:29 AM

  • Is it possible to change values in pagination select list for a report?

    The values showing up in my pagination select list for a report are 10,15,20,30,50,100,200,500,1000,5000.
    Is it possible to not have this list show the 1000 and 5000 values? I've tried setting various row values in the layout and pagination section of the report, but nothing changes in the select list. Is there a way to change this, or is it set up in a template somewhere that I can change?
    APEX version 3.0
    Thanks

    Figured this one out. Using the P1_ROWS item, added a static LOV with the correct values to override the one APEX was providing. The P1_ROWS item goes in the Number of Rows (Item) field in the layout and pagination section of the report.

  • Input Negative values in selection screen  for select-options field

    I am not able enter negative values for
    SELECT-OPTIONS V_ERFMG FOR MSEG-ERFMG.
    It says negative values are not allowed but I need to check for negative values. Kindly provide me solution.

    You can't put the negative values here...because the Domain which is attached to MSEG-ERFMG has not the "Sign" checkbox on.
    Try with this code:
    tables:wbrp.
    SELECT-OPTIONS V_ERFMG FOR WBRP-menge.
    Regards,
    Naimesh Patel

  • Search help: default value for 'Maximum no of hits'

    Hello,
    I have a request from a user to change the default value for maximum number of hits in the search help.
    Any quick hint?
    Regards,
    Michal

    Not sure if this is possible and don't have a SAP system available at the moment ...
    But check this out...
    Is there anything in user profile ..
    or check if the number of hits field has a PARAMETER ID associated with it...
    Then in that case you might default a value other than 500 in your user profile.
    Cheers,
    Ram

  • Depriciation for asset with limit on maximum value

    Hello,
    We have a requirement in which we have a limit on maximum value of the asset on which depreciation is allowed. For example is asset value is more than 100000 then depreciation should be allowed only for value 100000 and the depreciation should be spread across the useful life of the asset.
    I have an asset having value 300000 and I am able to post depriciation only for 2 years (50000 each) whereas the useful life of asset is 6 years.
    What I want is that the depreciation should be posted for 6 years with value (100000/6) 16666.67 each year.
    Has anyone come across the similar business scenario earlier?
    Any pointer to this will be of great help.
    Thanks
    Jyoti

    Hi,
    I found the solution.
    IT can be done by defining the maximum value of the asset in the SPRO path
    AA-> valuation mentods> further settings> define maximum base value.
    Jyoti

Maybe you are looking for

  • Time capsule losing internet connection

    Hey there, I've read other people with similar issues, but haven't found a solid resolution yet. Hoping you awesome Mac folks can help me out. It's slightly confusing, but please let me know what you think. Sorry this is long, just trying to give the

  • Need to include new field for RX-only: Financial Tax Register Report

    Hi All, In Report eXchange Designer responsibility > Setup RXi> Report Name filed > RX-only: Financial Tax Register Report Here in available filed we have some options when selected to display filed and run the report in Tax Manager only those select

  • SetCustomDatum and setObject performance

    I'm using the Object-Relational features of Oracle 8i. I've been experiencing a performance problem with setCustomDatum() or setObject() to set a user defined object in an OraclePreparedStatement to insert the object into the database. The performanc

  • Sending an username and a password with SSL but without Authentication

    Hi, I've read several threads about this topic but I'm still confused. I need to send a login and a password in a more or less secure way (not sending it in the get/post and not using a base64 encoding), but I don't want authentication, just to send

  • Sales doc type issue

    Hello friends, while copying the doc typeZOR from standard doc type OR,which fields will not copy ,recently i have faced this question? Regards, siva