Problem: Select  Database  to get  X highest entries in reagrd to one field

Hi Forum,
I have a problem regarding a complicated (at least for me) Select statement. It uses a customer Z-table to read certain data.
But my goal is to read only a certain number of top entries per store.
The number can change from one run to the other.
To make it clearer here is the simplified defintion of the database table
MANDT
LOCNR
DELTAVERS
LOCNR is a store and DELTAVERS is a version (simple counter 001,002,..)of that entry. Both fields are key fields.
Of course there additional fields with values that I interested in. But they are left out here to let focus on the problem.
My goal is to read a certain #number of top DELTAVERS (versions) for each LOCNR(Store). I do not know the stores or the # of DELTAVERS.
The select should provide a internal table showing the X highest DELTAVERS with the related store
e.g. A Select that should show the 3 highest DELTAVERS per Store LOCNR, if available
LOCNR: DELTAVERS:
N001 0013
N001 0023
N001 0024
B235 0021
B235 0056
Note: In this example B235 has only two entries
Code:
     l_having_by_cond = "count( DELTAVERS ) le  3".
       SELECT
                  locnr
                  deltavers
                  FROM z_locnr_version
                  APPENDING CORRESPONDING FIELDS OF TABLE
                  lt_locnr_version                 
                  GROUP BY locnr deltavers
                  HAVING (l_having_by_cond).
                  ORDER BY locnr deltavers DESCENDING.
lt_locnr_version should hold the desired result.
It seems to use the count for all entries and not just for each LOCNR.
Hoiw can I achive that the internal table holds the three highest DELTAVERS for each LOCNR (Store).
Or what would be the best solution here !? Remember we talking here about 1000+ Stores.
Please help !!
Thanks in advance,
Chris

Hi Forum
me again, I believe that I somewhat missunderstood the concept of GROUP BY and HAVING clause.
Both might prove completely useless in this case.
Would actually aa simple UP TO N ROWS do the tricking providing that the Select is done per store !?
How can I ensure that it gets always the TOP N entries!??
Thanks,
Chris
> Hi Forum,
>
> I have a problem regarding a complicated (at least
> for me) Select statement. It uses a customer Z-table
> to read certain data.
>
> But my goal is to read only a certain number of top
> entries per store.
> The number can change from one run to the other.
>
> To make it clearer here is the simplified defintion
> of the database table

> MANDT
> LOCNR
> DELTAVERS

>
>
> LOCNR is a store and DELTAVERS is a version (simple
> counter 001,002,..)of that entry. Both fields are key
> fields.
> Of course there additional fields with values that I
> interested in. But they are left out here to let
> focus on the problem.
>
> My goal is to read a certain #number of top DELTAVERS
> (versions) for each LOCNR(Store). I do not know the
> stores or the # of DELTAVERS.
>
> The select should provide a internal table showing
> the X highest DELTAVERS with the related store
>
> e.g. A Select that should show the 3 highest
> DELTAVERS per Store LOCNR, if available
>
>
> LOCNR: DELTAVERS:
> N001 0013
> N001 0023
> N001 0024
> B235 0021
> B235 0056
> ....
>
>
>
> Note: In this example B235 has only two entries
>
>
>
> Code:
>
>            
>      l_having_by_cond = "count( DELTAVERS ) le  3".
>
>        SELECT
>                   locnr
>                   deltavers
>
>                   FROM z_locnr_version
>                  
> APPENDING CORRESPONDING FIELDS OF
> SPONDING FIELDS OF TABLE
>                   lt_locnr_version                 
>                
>                   GROUP BY locnr deltavers
>                   HAVING (l_having_by_cond).
> ORDER BY locnr deltavers
> BY locnr deltavers DESCENDING.

>
>
> lt_locnr_version should hold the desired result.
>
> It seems to use the count for all entries and not
> just for each LOCNR.
> Hoiw can I achive that the internal table holds the
> three highest DELTAVERS for each LOCNR (Store).
>
> Or what would be the best solution here !? Remember
> we talking here about 1000+ Stores.
>
> Please help !!
>
> Thanks in advance,
>
> Chris

Similar Messages

  • Select the data from table which inbteween as well as one field if satisfy

    Tab1.   entries are below
    MANDT   SLRNO   BUKRS   ORDNR       FANLKL     TANLKL
    111                                 Ger          2           00110000       00110030
    111            000013         Ger          1            00110000       00130000
    111           000054          Ger          1             00110000     00130000
    111           000055          Ger           2             00110000     00110030
    111            000072         Ger          1             00110000      00130000
    111             000073        Ger          1             00110000     00130000
    111             000074       Ger           2             00110000     00110030
    111             000075       Ger          2              00110000     00110030
    111           000126         Ger          2             00160000      00160000
    lv-assetclass = u201800110020u2019 this is and company code is the only values which I have.
      which is inbetween 00110000    and    00110030
    So my below select statement should always give me sy-subrc = 0.
    select single FANLKL TANLKL
                  from Tab1
                  into (lv_var1, lv_var2)
                 where   BUKRS = Lv_companycode  
                   and   ( FANLKL GE  lv-assetclass and TANLKL LE  lv-assetclass ).
              if  sy-subrc <> 0.
                Codes are there.
              Endif.
    But it is giving sy-subrc = 4.So it satisfies the if statement and what ever the code part is there in ifu2026endif that is executed.
    My requirement is if lv-assetclass is 00110000 or 00110030 or inbetween these two values 00110020 for all the sy-subrc = 0.Even 00120000 should also give me sy-subrc 0 as 6th line is having entry 00110000     00130000  and 00120000 is coming under this.it should give me Sy-subrc = 0 when I put  lv-assetclass as 00110000 also.
    Can any one help me out in his select statement.
    Regards,
    Partha

    Hi,
    Change your Select Query as:
    select single FANLKL TANLKL
    from Tab1
    into (lv_var1, lv_var2)
    where BUKRS = Lv_companycode
    and ( FANLKL LE lv-assetclass and TANLKL GE lv-assetclass ).

  • Select on MARA resulting into # values in internal table for one field

    Hi Team,
    I have written a SELECT statement on MARA table as below.
    TRY.
            SELECT matnr zzwftag FROM mara CLIENT SPECIFIED
              INTO CORRESPONDING FIELDS OF TABLE gt_mara WHERE
              mandt = sy-mandt AND
              zzwftag NE space
              AND zzwftag IS NOT NULL
              AND zzwftag NE '#'
              AND zzwftag NE '%#%'
              AND zzwftag NE '  '
              AND zzwftag NOT LIKE '%/%'(012).
          CATCH cx_sy_dynamic_osql_error.
            MESSAGE 'Error While Fetching Data from MARA'(044) TYPE 'S'(040)  DISPLAY LIKE 'W'(041).
        ENDTRY.
        IF NOT gt_mara[] IS INITIAL.
          DELETE gt_mara[] WHERE zzwftag EQ '#'
          OR zzwftag IS INITIAL
          OR zzwftag EQ space
          OR zzwftag EQ ' '.
        ENDIF.
    Observations: 1. In
    the resulting internal table I am seeing '#' values for fields zzwftag which are actually empty when I see the record in SE11 in MARA(ALV display). It shows '#' in it in SE16 display(We can choose User parameters and hence mode of display in SE11)
    The requirement is to avoid those records where zzwftag is initial i.e. blank. I tried to delete invalid records but to no avail.
    Please suggest any way where I can get the Select correct.
    Regards,
    Amit

    Please do not use so many not conditions in one query....
    Using so many negative conditions results in bad data.
    Instead use delete statements later this would not confuse the system.
    Also if you are using sy-mandt then i think you should not use client specified system will take care of it.
    TRY.
    SELECT matnr zzwftag FROM mara CLIENT SPECIFIED
    INTO CORRESPONDING FIELDS OF TABLE gt_mara WHERE
    mandt = sy-mandt AND
    zzwftag NE space.
    CATCH cx_sy_dynamic_osql_error.
    MESSAGE 'Error While Fetching Data from MARA'(044) TYPE 'S'(040) DISPLAY LIKE 'W'(041).
    ENDTRY.
    IF NOT gt_mara[] IS INITIAL.
    DELETE gt_mara[] WHERE zzwftag EQ '#'
    OR zzwftag IS INITIAL
    OR zzwftag EQ space
    OR zzwftag EQ ' '.
    delete gt_mara[] where zzwflag eq '%#%'.
    ENDIF.

  • How to get Safari to suggest passwords when only one field is present?

    Safari works great when there are two fields to enter a password - a password field followed by a "confirm password" field - but doesn't seem to work when there is only one field to enter a new password.  Any suggestions?

    Hi,
    we have done something like this using seltab.
    One inputfield, user can enter anything same like in google like
    name:ab*,dob:1972
    write a conversion method to parse this input to seltab like
        clear ls_seltab.
        ls_seltab-sign  = 'I'.
        if lv_value cs '*'.
          li_lng = sy-fdpos.
          ls_seltab-option = 'BT'.
        else.
          ls_seltab-option = 'EQ'.
          ls_seltab-low    = lv_value.
        endif.
    use your seltab to retrieve data from the table.
    In anyway.. you can search resources in this direction to build your solution.

  • At Line-selection in ALV for more than one field.

    How to use At Line-selection in ALV Basic Report where there are more than one field for displaying Secondary Lists.
    Ex: In Basic List there are 3 fields Volume_m Volume_y and Volume_i.When i click on any of the field i need to display the secondary list for that particular field.

    Hi Pavan,
                  Use User-command event of ALV.
    Refer this code :
    form BUILD_EVENTCAT  using    p_i_eventcat TYPE SLIS_T_EVENT.
    DATA: I_EVENT TYPE SLIS_ALV_EVENT.
    CALL FUNCTION 'REUSE_ALV_EVENTS_GET'
    EXPORTING
       I_LIST_TYPE           = 0
    IMPORTING
       ET_EVENTS             = P_I_EVENTCAT
    EXCEPTIONS
      LIST_TYPE_WRONG       = 1
      OTHERS                = 2
    IF sy-subrc <> 0.
    MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
             WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
    ENDIF.
      clear I_event.
      read table p_i_eventcat with key name = slis_ev_user_command into I_event.
      if sy-subrc = 0.
        move 'USER_COMMAND' to I_event-form.
        append I_event to p_i_eventcat.
      endif.
    form USER_COMMAND' using p_ucomm type sy-ucomm
                               p_selfield type slis_selfield.
      case p_ucomm.
      WHEN '&IC1'.                       "&IC1 is the Fcode for double click
    Use  P_ELFIELD-VALUE  for further processing . this  will contain the value on which u will double click
    endcase.
    Reward points if helpful.
    Regards,
    Hemant

  • After years of no problems I can't print photos. When I select print I get the message "There are no themes located. Until at least one theme has been installed this feature will be unavailable.  What are themes? How do I install them?

    After years of no problems I sddenly can't print photos. When I select print I get the message "There are no themes located. Until at least one theme has been installed this feature will be unavailable.  What are themes? How do I install them? Why has this problem suddenly arisen?

    Re-installing does not affect your Library in any way. You don't delete it, only the app.
    To re-install iPhoto
    1. Put the iPhoto.app in the trash (Drag it from your Applications Folder to the trash)
    2a: On 10.5:  Go to HD/Library/Receipts and remove any pkg file there with iPhoto in the name.
    2b: On 10.6: Those receipts may be found as follows:  In the Finder use the Go menu and select Go To Folder. In the resulting window type
    /var/db/receipts/
    2c: on 10.7 they're at
    /private/var/db/receipts
    A Finder Window will open at that location and you can remove the iPhoto pkg files.
    3. Re-install.
    If you purchased an iLife Disk, then iPhoto is on it.
    If iPhoto was installed on your Mac when you go it then it’s on the System Restore disks that came with your Mac. Insert the first one and opt to ‘Install Bundled Applications Only.
    If you purchased it on the App Store or have a Recent Mac you can find it in your Purchases List.
    Regards
    TD

  • Problem connecting DataBase Link from windows oracle to oracle on Linux

    I'm facing a problem with database links from windows oracle to Oracle hosted on Linux server.
    I'm able to successfully create the Database Link using the following query on oracle database hosted on a windows server
    CREATE DATABASE LINK SampleDB
    CONNECT TO myuser IDENTIFIED BY password
    USING 'sample';
    The tns names entry on windows for database in Linux server is as follows
    DSOFT =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.100)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = sample)
    But while executing the query "select count(*) from doctor@SampleDB;" in sql developer on windows, I'm getting the following error
    SQL Error: ORA-12154: TNS:could not resolve the connect identifier specified
    12154. 00000 - "TNS:could not resolve the connect identifier specified"
    *Cause:    A connection to a database or other service was requested using
    a connect identifier, and the connect identifier specified could not
    be resolved into a connect descriptor using one of the naming methods
    configured. For example, if the type of connect identifier used was a
    net service name then the net service name could not be found in a
    naming method repository, or the repository could not be
    located or reached.
    Using the above tns entries, i'm successfully able to connect to the database in Linux server through sql developer installed on the windows machine. Then why i'm getting this error while executing the query on Database Link?. Can any one help me?

    1005745 wrote:
    I'm facing a problem with database links from windows oracle to Oracle hosted on Linux server.
    I'm able to successfully create the Database Link using the following query on oracle database hosted on a windows server
    CREATE DATABASE LINK SampleDB
    CONNECT TO myuser IDENTIFIED BY password
    USING 'sample';
    The tns names entry on windows for database in Linux server is as follows
    DSOFT =
    (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.100)(PORT = 1521))
    (CONNECT_DATA =
    (SERVICE_NAME = sample)
    But while executing the query "select count(*) from doctor@SampleDB;" in sql developer on windows, I'm getting the following error
    SQL Error: ORA-12154: TNS:could not resolve the connect identifier specified
    12154. 00000 - "TNS:could not resolve the connect identifier specified"
    *Cause:    A connection to a database or other service was requested using
    a connect identifier, and the connect identifier specified could not
    be resolved into a connect descriptor using one of the naming methods
    configured. For example, if the type of connect identifier used was a
    net service name then the net service name could not be found in a
    naming method repository, or the repository could not be
    located or reached.
    Using the above tns entries, i'm successfully able to connect to the database in Linux server through sql developer installed on the windows machine. Then why i'm getting this error while executing the query on Database Link?. Can any one help me?A database link is acting as a client to the target, remote database in exactly the same fashion and using exactly the same tns infrastructure as any other client trying to connect to that remote database. your ORA-12154 when querying a db link means exactly the same as if you had gotten it trying to connect with sqlplus, from the same server. Check the link SB provided. Keep in mind that the tnsnames file of concern is the one on the source database server.

  • Interactive report performance problem over database link - Oracle Gateway

    Hello all;
    This is regarding a thread Interactive report performance problem over database link that was posted by Samo.
    The issue that I am facing is when I use Oracle function like (apex_item.check_box) the query slow down by 45 seconds.
    query like this: (due to sensitivity issue, I can not disclose real table name)
    SELECT apex_item.checkbox(1,b.col3)
    , a.col1
    , a.col2
    FROM table_one a
    , table_two b
    WHERE a.col3 = 12345
    AND a.col4 = 100
    AND b.col5 = a.col5
    table_one and table_two are remote tables (non-oracle) which are connected using Oracle Gateway.
    Now if I run above queries without apex_item.checkbox function the query return or response is less than a second but if I have apex_item.checkbox then the query run more than 30 seconds. I have resolved the issues by creating a collection but it’s not a good practice.
    I would like to get ideas from people how to resolve or speed-up the query?
    Any idea how to use sub-factoring for the above scenario? Or others method (creating view or materialized view are not an option).
    Thank you.
    Shaun S.

    Hi Shaun
    Okay, I have a million questions (could you tell me if both tables are from the same remote source, it looks like they're possibly not?), but let's just try some things first.
    By now you should understand the idea of what I termed 'sub-factoring' in a previous post. This is to do with using the WITH blah AS (SELECT... syntax. Now in most circumstances this 'materialises' the results of the inner select statement. This means that we 'get' the results then do something with them afterwards. It's a handy trick when dealing with remote sites as sometimes you want the remote database to do the work. The reason that I ask you to use the MATERIALIZE hint for testing is just to force this, in 99.99% of cases this can be removed later. Using the WITH statement is also handled differently to inline view like SELECT * FROM (SELECT... but the same result can be mimicked with a NO_MERGE hint.
    Looking at your case I would be interested to see what the explain plan and results would be for something like the following two statements (sorry - you're going have to check them, it's late!)
    WITH a AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_one),
    b AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_two),
    sourceqry AS
    (SELECT  b.col3 x
           , a.col1 y
           , a.col2 z
    FROM table_one a
        , table_two b
    WHERE a.col3 = 12345
    AND   a.col4 = 100
    AND   b.col5 = a.col5)
    SELECT apex_item.checkbox(1,x), y , z
    FROM sourceqry
    WITH a AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_one),
    b AS
    (SELECT /*+ MATERIALIZE */ *
    FROM table_two)
    SELECT  apex_item.checkbox(1,x), y , z
    FROM table_one a
        , table_two b
    WHERE a.col3 = 12345
    AND   a.col4 = 100
    AND   b.col5 = a.col5If the remote tables are at the same site, then you should have the same results. If they aren't you should get the same results but different to the original query.
    We aren't being told the real cardinality of the inners select here so the explain plan is distorted (this is normal for queries on remote and especially non-oracle sites). This hinders tuning normally but I don't think this is your problem at all. How many distinct values do you normally get of the column aliased 'x' and how many rows are normally returned in total? Also how are you testing response times, in APEX, SQL Developer, Toad SQLplus etc?
    Sorry for all the questions but it helps to answer the question, if I can.
    Cheers
    Ben
    http://www.munkyben.wordpress.com
    Don't forget to mark replies helpful or correct ;)

  • Check "Problem: Oracle Database 10g Release 2 can only be installed in new

    Hi All
    Installing 10g software on AIX Box in /oracle/oraHome2,where oracle9i is already installed in /oracle/oraHome1 and oracle inventory is in /oracle/inventory
    In product specific prerequisite screen I am getting the
    check:Oracle Home incompatibilties is failed I am getting the error
    Check complete. The overall result of this check is: Passed
    =======================================================================
    Checking for Oracle Home incompatibilities ....
    Actual Result: Oracle9i Database 9.2.0.1.0
    Check complete. The overall result of this check is: Failed <<<<
    Problem: Oracle Database 10g Release 2 can only be installed in a new Oracle Home
    Recommendation: Choose a new Oracle Home for installing this product
    though I am installing it in different oracle homes why i am getting this error?
    Is it because 10g installation is picking the same oracle inventory /oracle/inventory
    do i need to make different oracle inventory for different oracle homes???????plz confirm..is thats the reason i am getting this error??????
    Thanks inadvance
    Gagan

    I figure out you are trying to install 10gR2 on top of an existing 9iR2 Oracle Home. This is corrected at the Path definition window. Most probably you just click on the <Next> and by default the 9iR2 Oracle Home was selected. You must define a new oracle home for the 10gR2 install.
    ~ Madrid

  • Select the filter value display "No Entries Found"

    Hi All,
    I have a problem with the bex query. Query is built on a multiprovider.
    I am using restricted key figure with constant selection checked for the characteristic that is available only in one cube.
    Because of this when I right click and select Filter values on the free characteristics from the report, I get “(No Entries Found)”
    If I remove constant selection from the key figure, report works fine.
    Can someone help with a solution;
    Thanks,
    Biju

    Assuming your data is coming from only one cube...
    Drag 0INFOPROV in your Filter and restrict it with your your Cube
    You can find 0INFOPROV in Dimensions under Data package
    Hope this helps.

  • Can't get a blank entry in Choice List of Values (LOV)

    Using Jdev 11.1.1.3 but will be upgrading to 11.1.1.5 in few weeks.
    Need to display a Choice List that is bound a view object with static data. The List should show a blank item since users don’t need to select any.
    I am able to display the LOV in the page but can’t seem to get a blank item as a first item.
    Here is what I did:
    1.     Created the VO with static data. Initially didn’t include it in the Application Module based on the developer guide sec 5.3 but later added to get it in the data control list.
    (Note the application doesn’t need to use any database and simply is using Web Service but for test I am using a DB)
    2.     To configured the VO, tried to add a View Accessor to the VO, but couldn’t select a data source until I added the VO to the App Module !
    3.     In attributes tab added an LOV and specified the data source. In UI Hints ensure the “Include “No Selection” Item” was selected.
    (Initially didn’t shuttle the attribute to the right in the UI hints.)
    4.     In the List UI hints ensured that “Include “No Selection” Item” was selected.
    5.     Dragged the VO Data control to the page and selected ADF Select One Choice.
    6.     On running the List DID NOT include a blank item !? How to get one?
    In pageDef got:
    <list IterBinding="GenderListVO1Iterator" ListOperMode="navigation"
    ListIter="GenderListVO1Iterator" id="GenderListVO1"
    DTSupportsMRU="true">
    <AttrNames>
    <Item Value="Gender"/>
    </AttrNames>
    </list>
    I even added the tag NullValueFlag="start" to the PageDef but no blank entry.
    In Page got:
    <af:selectOneChoice value="#{bindings.GenderListVO1.inputValue}"
    label="#{bindings.GenderListVO1.label}"
    required="#{bindings.GenderListVO1.hints.mandatory}"
    shortDesc="#{bindings.GenderListVO1.hints.tooltip}"
    id="soc3">
    <f:selectItems value="#{bindings.GenderListVO1.items}" id="si7"/>
    </af:selectOneChoice>
    If I don't use the VO and code all items in the JSPX page with a blank item that get a blank entry (didn't test with the Web Service yet since not ready).
    What is the issue with VO?
    ( I am also considering a number of SelectManyChecks on the same page but might be difficult)
    Thanks for the reply.
    Edited by: user8769031 on Jun 10, 2011 11:12 AM

    Thanks for the hint, but in my case the attribute is not required. I never see a blank entry. The only way I was able to get a blank is to add a blank item to the static list in the VO. The VO XML file has:
    <LOVUIHints
    ListType="105"
    MRUCount="0"
    ListRangeSize="-1"
    NullValueFlag="start"
    NullValueId="LOVUIHints_NullValueId">
    The Include "No selection" item is not working as expected.

  • I downloaded iTunes onto my laptop and kept getting an Apple Application error so I also downloaded that and now I'm getting a Procedure Entry Point error as well as Error 7 (Windows Error 127) and I have no clue what to do. Can anyone help me?

    I downloaded iTunes onto my laptop and was getting an Apple Application Support error so I downloaded that and now I'm getting a Procedure Entry Point and Error 7 (Windows Error 127) messages. I have no clue how to go about fixing whatever the problem is...can anyone help me?

    iTunes.exe - Entry Point Not Found
    The procedure entry point
    AVCFAssetCreatWithByteStreamAndOptions could not be located in the dynamic link library AVFoundationCF.dll.
    Taken at face value, you're having trouble with an Apple Application Support program file there. (Apple Application Support is where single copies of program files used by multiple different Apple programs are kept.)
    Let's try something relatively simple first. Restart the PC. If you're using Vista or 7,now head into your Uninstall a program control panel, select "Apple Application Support" and then click "Repair". If you're using XP, head into your Add or Remove Programs control panel, select "Apple Application Support", click "Change" and then click "Repair".
    If no joy after that, try the more rigorous uninstall/reinstall procedure from the following post. (If you've got XP, although the procedure is for Vista and 7, just read "Computer" as "My Computer", read "Uninstall a program control panel" as "Add or Remove programs control panel" and assume the system is 32-bit, and you'll be doing the right things.)
    Re: I recently updated to vista service pack 2 and I updated to itunes 10.2.1 and ever

  • SELECT ... FOR ALL ENTRIES IN fails!!!

    Hi,
    we are on Kernel 640_REL unicode and found a Kernel error:
    Using SELECT ... FOR ALL ENTRIES IN with a field list to be retrieved,  the ABAP-Database interface obviously deletes duplicate records.
    Our scenario is retrieval of open special ledger postings for customers from BSID.
    The fields specified were
    BUKRS KUNNR WAERS DMBTR WRBTR SHKZG UMSKZ
    If a customer has more than one matching record with the same amount, only one of those is returned. The only way to get all matching records is to retrieve all key fields.
    I forwarded to the people handling OSS-requests in our project. Before we get the solution, i want to issue a severe warning.
    This failure is decribed in note 65554 for Kernel-Release <= 3.0F and <= 4.6D, also Release 6.10. But nothing newer.
    After all those years of ABAP I did not expect they can't handle SQL.
    regards,
    Clemens

    Hi Clemens
    If I understand your post, I don't think there is an error, the following is from the online help:
    "The result set of the SELECT statement is the union of the individual selections for each line of the internal table. Duplicate lines are automatically eliminated from the result set. If <itab> is empty, the addition FOR ALL ENTRIES is disregarded, and all entries are read. "
    I believe that 'FOR ALL ENTRIES' is a union and therefore duplicate rows are removed.  If you want each row to appear then you need to make the row unique by using all the key fields. I think it would also be better to inlcude all the key fields in the WHERE clause anyway.
    Kind regards
    Andy

  • Get second-highest element in hierarchy

    It's Friday afternoon and my brain isn't working well, and some of you people I'm sure will have the answer in a flash....
    I have a typical hierarchical table, here's an example below;
    with codes as
    (select 17 icode,     -1 parent_code,'Group Services' descrip from dual
    UNION
    select 18,     -1,     'Counselling' from dual
    UNION
    select 20,     -1,     'Career Decision Making' from dual
    UNION
    select 21,     20,     'Career Assessment' from dual
    UNION
    select 22,     20,     'Academic Assessment' from dual
    UNION
    select 27,     22,     'Fee' from dual
    UNION
    select 28,     22,     'Transportation' from dual
    UNION
    select 33,     28,     'In-Province' from dual
    UNION
    select 34,     21,     'Fee' from dual
    UNION
    select 35,     21,     'Transportation' from dual
    UNION
    select 39,     35,     'Daily' from dual),
    intervs as
    (select 17 interv from dual
    union select 18 interv from dual
    union select 27 interv from dual
    union select 33 interv from dual
    union select 34 interv from dual
    union select 39 interv from dual)
    select interv,x.*
    from intervs
    INNER JOIN (select l1.icode k1,l1.descrip d1,
    l2.icode k2 ,l2.descrip d2,
    l3.icode k3 ,l3.descrip d3,
    l4.icode k4,l4.descrip d4
    from codes l4
    left outer join codes l3 ON l3.icode = l4.parent_code
    left outer join codes l2 ON l2.icode = l3.parent_code
    left outer join codes l1 ON l1.icode = l2.parent_code)
    x ON x.k4 = intervs.interv
    What I would like to get for each intervs.interv is the k/d pair that is the second highest element in the hierarchy, or if there is no higher level in the hierarchy I'll take that.
    So in the data that the above displays, I'd like 22 - academic assessment for #33,
    21 Career Assessment for #34, and 18 and 17 would come back as themselves.
    Thanks in advance,
    Jon

    or you can use the tradtional sql, it can run in most database
    select * from scott.emp t11,
    --get the second highest sal
    select deptno, max(sal) sal
    from
    ( --get the highest sal
    select t1.deptno, t1.empno, t1.ename, t1.sal from scott.emp t1,
    ( select deptno,max(sal) max_sal
    from scott.emp e
    group by deptno
    ) t2
    where t1.deptno=t2.deptno
    and t1.sal<t2.max_sal
    order by t1.deptno asc,sal desc
    ) t
    group by t.deptno
    order by t.deptno
    ) t22
    where t11.deptno=t22.deptno
    and t11.sal=t22.sal;

  • UCCX 9.0.2 DB Get step in CCX Editor will not save Field Selection Values. DB Read Working

    Good Evening All!
    I've got a strange one for you (strange to me at least). I'm building a script that does an MS SQL database dip. I have configured the DB Read step with a query that returns entries from a single table and in the "Success" Label area I have put a DB Get function. I see the data source from DB Read in the General tab and select it, that part behaves correctly. I then go the Field Selection tab and add a value (or values) (see screen shot). This would appear to work correctly. I then do an apply but nothing gets set in the DB Get function. What am I doing wrong? I'm willing to be its something simple. Any guidance you all can provide would be greatly appreciated.
    Many Thanks!
    Justin

    Hi,
    it's kind of hard to see as we don't see your configured data sources. Anyway, did you try reactive debugging? I recommend you insert Annotation steps so when you actually execute the script step by step, you see what the DB GET step returns and what exit it takes. Like this:
    This way you will be able to see what's wrong and also the value of sAgentID.
    One more thing: it's always recommended to use the DB Release step once you finish your database operations. It basically tells UCCX that it can return the database connection to the pool so it may be available for another thread. Like this:
    G.

Maybe you are looking for

  • Ipod sync issues with itunes 11

    Hello, My classic iPod syncs very slowly with iTunes 11, it starts out syncing (2 songs) & then just "sits" with no progress. iPod sofware is up to date, version 1.1.2. Any help appreciated. Thanks Lee

  • server :19000/hfm not available - causing issues

    1. 11.1.2.2 Distributed Environment - Foundation server I can access <foundationhostname>:19000/hfm just fine. However, if I copy and paste that onto another server and try to hit the web address <foundationhostname>:19000/hfm - I get a HTML 500 erro

  • Save Target As in IE Opens PDF in a New Window Instead of Downloading

    I work in the IT department at a UK firm of solicitors and we have recently observed issues with using "Save Target As" in Internet Explorer 8 on Windows 7 with Reader XI. Instead of prompting for the path to save the file, as you would expect, it in

  • Distribution channels deviate from each other.70 /or 10 (reference), Message no. V2011

    I have a problem when create the "Credit memo request" doc. type CR, reference doc. is billing doc. and my sales doc. that i did the billing doc. sales area is 2100/10/71 and i have to create cr doc with reference to billing doc. and sales area shoul

  • PDF Illustrator Problems

    Hello, I am having problems with CS5 Illustrator, anytime I try to save as a pdf it freezes. It can be a blank page and it still freezes. It shows in task manager as still working but I let it sit for 20 min and still no save.Help plz! Thanks