Select Distinct and join in ODI

Hi,
I have following task to perform: I am loading metadata into Planning dimension from Oracle database. I have two tables
1. "Sales"
Columns: Name, Number, Value
Sample Data:
Product 1, 10, 200
Product 2, 30, 100,
Product 1, 15, 500
2. P&R
Columns:
Name, Alias
Product 1, SampleSoda1
Product 2, SampleSoda2,
Resource 1, CanForSoda,
Resource 2, CO2
What I need to do is: I have to select name and alias from second table of all products that were sold.
So I need to select distinct Name from Table 1, naxt join it with Table 2 (so I have Name and Alias) and load it to planning.
I am a little confused how to do it.
Any help would be great!
Best regards,
Greg

Hi Greg,
What you can do is either :
- Create a yellow interface with your table Sales as source. Map the name column directly in the target. In the flow tab, click on your target and select "Distinct rows".
- Create a second interface, with your first interface as source. Select the "Use Temporary Interface as Derived Table (Sub-Select)" checkbox.
- Add your second datastore and join it. Or you can use a lookup table.
OR
- Create an interface with Sales and P&R as source (or set P&R as a lookup table).
- Go on the flow tab and select "Distinct rows".
If you've a lot a data in the first table, I would go for the first solution.
Hope it helps.
Regards,
JeromeFr
Edited by: JeromeFr on Feb 14, 2013 9:52 AM
To be more clear in the first step of solution 1

Similar Messages

  • Select distinct and 2 inner joins in same select statement

    can anyone guide me how to write the below query for higher performance. can I use for all entires or shall i split this,
    please let me know your opinions.
    SELECT DISTINCT werks matnr b~stlal idnrk postp d~aennr
       sortf potx1 c~lkenz b~stlty stlst
       INTO TABLE ltab_one
       FROM mast AS a INNER JOIN stko AS b
         ON  a~stlnr = b~stlnr
         AND a~stlal = b~stlal
         INNER JOIN stas AS c
         ON  b~stlnr = c~stlnr
         AND b~stlal = c~stlal
         AND b~stlty = c~stlty
         INNER JOIN stpo AS d
         ON  c~stlnr = d~stlnr
         AND c~stlkn = d~stlkn
         AND c~stlty = d~stlty
      WHERE a~werks IN s_werks
         AND ( ( d~andat IN s_datum
            OR d~aedat IN s_datum
            OR a~andat IN s_datum
            OR a~aedat IN s_datum
            OR b~andat IN s_datum
            OR b~aedat IN s_datum
            OR c~andat IN s_datum
            OR c~aedat IN s_datum
            ) AND d~datuv >= lv_effdt )
         AND a~stlan = '1'
         AND matnr IN s_matnr.

      WHERE a~werks IN s_werks
         AND ( ( d~andat IN s_datum
            OR d~aedat IN s_datum
            OR a~andat IN s_datum
            OR a~aedat IN s_datum
            OR b~andat IN s_datum
            OR b~aedat IN s_datum
            OR c~andat IN s_datum
            OR c~aedat IN s_datum
            ) AND d~datuv >= lv_effdt )
         AND a~stlan = '1'
         AND matnr IN s_matnr.
    This part determines your performance, not the DISTINCT and not the joins.
    What is in s_werks, s-datum, s_matnr typically? I guess there are better and worse conditions.

  • SELECT DISTINCT with JOIN

    Hi,
    how Do I write this select in rigth way in ABAP
    SELECT ska1ktopl AS ktopl ska1saknr AS saknr
        t370k_t~eartx AS eartx
        INTO  TABLE lt_ska1 FROM ska1
        JOIN (SELECT DISTINCT damage_gl FROM  zzpm_cost_elem )  ON ska1saknr = zzpm_cost_elemdamage_gl.
    The problem with the select "SELECT DISTINCT damage_gl FROM  zzpm_cost_elem " which I have to put table name instead of it
    What should I do ?
    Thx

    Hi Friend ,
    Please see this example  how you can use the select DISTINCT statement
    DATA: ITAB TYPE STANDARD TABLE OF SPFLI,
          WA LIKE LINE OF ITAB.
    DATA: LINE(72) TYPE C,
          LIST LIKE TABLE OF LINE(72).
    LINE = ' CITYFROM CITYTO '.
    APPEND LINE TO LIST.
    SELECT DISTINCT (LIST)
           INTO CORRESPONDING FIELDS OF TABLE ITAB
           FROM SPFLI.
    IF SY-SUBRC EQ 0.
      LOOP AT ITAB INTO WA.
        WRITE: / WA-CITYFROM, WA-CITYTO.
      ENDLOOP.
    ENDIF.
    Regards,

  • Diff b/w lookup and join in odi

    Hi friends,
    I am new to ODI ,
                   Please can anyone explain the difference between "join" and "lookup" ?
    Thanks in advance !
    Cnu

    Hi,
    Have a look
    https://forums.oracle.com/thread/2470379
    Thanks

  • Select Query and Join Between int and Numeric(22)

    I have two tables
    tablea
    Field1 int
    tableb
    Field1 Numeric(22)
    I know this design is wrong but this is what I have ?
    tablea contains about 12M records
    Field1 in tablea is one to one related to Field1 in tableb
    Now I have Select Query
    Select tablea.* from tablea,tableb where tablea.field1=tableb.field1 and tableb.field2 > somrthing
    Query here is
    Does Join Between
    int type

    Yes, avinash said rightly.
    there is another way bit diffict.
    use the indexes properly as available in the mseg table and mkpf table even then it is diffcult
    else try using BAPI.
    some bapi will give the entire details of the MATERAIL DOCUMENT
    go to BAPI explorer tcode BAPI.
    where you can find the BAPI name like the 'GET_LIST'.
    Try this.
    hope this will serve your purpose.
    Thanks and regards
    Ramchander Rao.K

  • Select query and join's

    Hi All,
    I had to modify the current select query coz its taking a lot of database time, please suggest the best solution for the below.
    SELECT msegbukrs mkpfbudat mkpf~bldat
    msegebeln mkpfxblnr mseg~mblnr
    msegmjahr msegzeile mseg~xauto
    msegparent_id msegwerks mseg~umwrk
    msegumlgo msegparent_id ekko~reswk
    msegwerks mseglgort mseg~matnr
    msegerfmg msegerfme mseg~shkzg
    msegsjahr msegsmbln mseg~smblp
    msegcharg ekkobedat
    INTO TABLE g_tbl_main
    FROM mkpf JOIN mseg
    ON mkpfmandt = msegmandt AND
    mkpfmblnr = msegmblnr AND
    mkpfmjahr = msegmjahr
    JOIN ekko ON msegmandt = ekkomandt AND
    msegebeln = ekkoebeln
    JOIN likp  ON mkpfxblnr = likpvbeln
    CLIENT specified
    WHERE mkpf~mandt = sy-mandt AND
    mkpf~budat IN s_budat AND
    ekko~bedat IN s_bedat AND
    mseg~ebeln IN s_ebeln AND
    mkpf~xblnr IN s_vbeln AND
    likp~vstel IN s_vstel AND
    ekko~reswk IN s_reswk AND
    mseg~werks IN r_werks AND
    mseg~lgort IN s_lgort AND
    mseg~matnr IN s_matnr AND
    mseg~smbln = space AND
    mseg~bwart IN s_bwart AND
    mseg~kzzug = c_true.

    Yes, avinash said rightly.
    there is another way bit diffict.
    use the indexes properly as available in the mseg table and mkpf table even then it is diffcult
    else try using BAPI.
    some bapi will give the entire details of the MATERAIL DOCUMENT
    go to BAPI explorer tcode BAPI.
    where you can find the BAPI name like the 'GET_LIST'.
    Try this.
    hope this will serve your purpose.
    Thanks and regards
    Ramchander Rao.K

  • Selecting Employees and Joins in PL/SQL using IF conditions

    how to get empno starts with 7 from emp and jobs is manager and sales manager and clerk those r joined in before 1981 year r in 1981
    i want pl/sql code for that one using if conditions

    {thread:id=2174552}
    {message:id=9360002}
    Short answer, read a book
    2 Day Developer's Guide
    http://docs.oracle.com/cd/E11882_01/appdev.112/e10766/toc.htm
    SQL Language Reference
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/toc.htm
    PL/SQL Language Reference
    http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/toc.htm
    Edited by: 3360 on Sep 10, 2012 9:26 AM
    Removed inappropriate thread specific text since post was moved by a moderator

  • OraException from Command.ExecuteReader with SELECT DISTINCT

    Hello
    I am trying to fill an OraDataReader object from a OraCommand object.
    It appears that whenever the statement includes a SELECT DISTINCT, the command fails (even though the SQL statement works fine when executed e.g. in TOAD)
    Dim Conn As OraConnection = New Oracle.DataAccess.Client.OraConnection("[Valid connection string]")
    Conn.Open()
    Dim Command As OraCommand = New OraCommand()
    Command.CommandType = CommandType.Text
    Command.CommandText = "select DISTINCT nvl(SUBFAMILY_COMPETENCY_ID, 0) SUBFAMILY_ID, nvl(NAME, ' ') NAME, FAMILY_COMPETENCY_ID FAMILY_ID " & _
    " from TAXONOMY_RELATIONAL, COMPETENCY " & _
    " where TAXONOMY_RELATIONAL.CL_ID = :1 " & _
    " AND COMPETENCY.cl_id (+) = TAXONOMY_RELATIONAL.cl_id and COMPETENCY.language_id (+) = :2 " & _
    " and COMPETENCY.COMPETENCY_ID (+) = TAXONOMY_RELATIONAL.SUBFAMILY_COMPETENCY_ID " & _
    " order by FAMILY_ID, SUBFAMILY_ID"
    Command.Parameters.Add("@CL_ID", context.Session!CLID)
    Command.Parameters.Add("@LANGUAGE_ID", context.Session!LANGUAGEID)
    Dim DataReader As OraDataReader = Command.ExecuteReader(CommandBehavior.CloseConnection)
    An Oracle.DataAccess.Client.OraException is raised when executing the last statement, but no further details are given in the error message. The stack trace begins as follows
    [OraException]()
    Oracle.DataAccess.Client.OraException.HandleErrorHelper(Int32 errCode, OraConnection conn, IntPtr opsErrCtx, IntPtr opsSqlCtx, Object src, String procedure) +639
    Oracle.DataAccess.Client.OraCommand.ExecuteReader(+737)
    Oracle.DataAccess.Client.OraCommand.ExecuteReader(CommandBehavior behavior) +8
    The exception disappears as soon as I remove the DISTINT keyword from my SQL statement.
    Is this a bug or am I doing something wrong?
    Thanks for help,
    Bernt Fischer

    This issue is same as the one mentioned in the thread with title "Problem with 'Select distinct'" and the fix would be available in the next release.

  • ODI: Way to select Distinct data while doing Join of tables at Source

    HI,
    Our requirement is to do a join on multiple tables selecting distinct data from those table at source.
    But we are not able to see the Distinct Box in flow tab.
    Any thoughts to resolve our problem
    Pratik

    You can not put DISTINCT clause selectively .
    If you choose to opt for DISTINCT then Oracle will apply the distinct to all columns present in the select list .
    So at your IKM level just click the distinct check box .. run your interface and find out the query generated .
    See if your requirement is getting fullfilled or not .
    Thank,
    Sutirtha

  • Pl sql join and selecting columns from join."t"."c": invalid at debug time

    I noticed the error at cc.Country that is shown because cc is not yet there at compile time (got that
    from searching this forum).
    Isnt that a bit weak of oracle sql developer that it doesnt compile from the outside to the inside /core but
    rather form top to bottom?
    Am I right with my conclusion? If so, how to do it otherwise i.e. specifying that cc.country is
    a column from countrycodes joined with table6 ?
    SELECT DISTINCT 0,
    2,
    SUBSTR('metable', 0, 1) || '_ABC',
    'ABC_' || 'metable',
    'ABC ' ||cc.Country ,
    '+'
    FROM table6
    LEFT JOIN COUNTRYCODE cc
    ON cc.Code = metable
    WHERE metable IS NOT NULL
    AND metable <> ''

    metalray wrote:
    hi Boneist
    thanks for your reply
    its in a plsql procedure (10g). well as you see cc is the alias
    of the table COUNTRYCODE. which does exists. the error is at 'ABC ' ||cc.Country'
    telling me"PL/SQL: ORA-01747: invalid user.table.column,..."
    when I put COUNTRYCODE next to table6 in the FROM it works but thats not what I want
    since I want to join both tables not just select from both.Can you give us your exact code and exact error message.
    I'm not finding any problem with using alias names in the query..
    SQL> select d.dname
      2        ,'EMPNAME : '||e.ename
      3  from dept d LEFT JOIN emp e ON e.deptno = d.deptno;
    DNAME          'EMPNAME:'||E.ENAME
    RESEARCH       EMPNAME : SMITH
    SALES          EMPNAME : ALLEN
    SALES          EMPNAME : WARD
    RESEARCH       EMPNAME : JONES
    SALES          EMPNAME : MARTIN
    SALES          EMPNAME : BLAKE
    ACCOUNTING     EMPNAME : CLARK
    RESEARCH       EMPNAME : SCOTT
    ACCOUNTING     EMPNAME : KING
    SALES          EMPNAME : TURNER
    RESEARCH       EMPNAME : ADAMS
    SALES          EMPNAME : JAMES
    RESEARCH       EMPNAME : FORD
    ACCOUNTING     EMPNAME : MILLER
    OPERATIONS     EMPNAME :
    15 rows selected.
    SQL>

  • Help! Howto use the join function in a query with select distinct ?

    Hi!
    I have 2 tables. I want to select only 1 painting of each artists.
    select distinct idartist
    from tbl_artworks
    where blah blah blah
    order by rand()
    how does the "join" function work for add: name, lastname, title, image and much more... i try... but i fail...
    tbl_artists
    idartist
    name
    lastname
    1
    Paul
    Gaugain
    2
    Vincent
    Van Gogh
    3
    Pablo
    Picasso
    tbl_artworks
    idartwork
    idartist
    title
    image
    1
    1
    days of gods
    image1.jpg
    2
    2
    sunflower
    image2.jpg
    3
    3
    Dora maar au chat
    image3.jpg
    4
    2
    Sky
    image4.jpg
    5
    3
    La vie
    image5.jpg

    Getting a single random image for each probably requires a combination of sql and cf.  It would take someone smarter than me to do it with sql alone.  I would probably try something like this:
    1.  Run a database query that gets all the images from all the artists.
    2.  Run a Q of Q that gets a distinct list of artist ids.
    3.  Loop through that list and run a Q of Q to get all the images for that artist.
    4.  Still in that loop, use randrange (1 to the recordcount) to select a random record from your Q of Q

  • Select DISTINCT attribute vlaues fom XMLTYPE column and...

    Hello
    I have spent whole day to find the solution with no success. PLEAS HELP !
    The Problem :
    1. I have table with xmlType column in this column is the following xml:
    <revision>
    <product id = 1>
    <screw>
    <img id = 1/>
    </screw>
    <screw>
    <img id = 2/>
    </screw>
    </product>
    <product id = 2>
    <screw>
    <img id = 1/>
    </screw>
    </product>
    </revision>
    I must select DISTINCT img IDs and then select/join them form relational table img (id(number), pic (blob) )
    I can't find the solution to select distinct attribute values from XML!
    I have tried this:
    select extract(c.xml, 'revision/product/screw/img[not(@id=preceding-sibling::img/@id)]/@id') from TABLE c;

    Hello Odie_63
    I have again problem finally my XML looks that:
    <revision>
    <product id = "1">
    <screw>
    <img id = "1"/>
    </screw>
    <component>
    <img id = "1"/>
    </component>
    <screw>
    <img id = "2"/>
    </screw>
    <component>
    <img id = "2"/>
    </component>
    </product>
    <product id = "2">
    <screw>
    <img id = "1"/>
    </screw>
    <component>
    <img id = "4"/>
    </component>
    </product>
    </revision>'));
    And I don't know why my following statement doesn't work. (I must slect all distinct id from <img>).
    select distinct x.img_id
    from cfg_xml t
    , xmltable(
    '/revision/definitions/product'
    passing T.EQ_CFG_XML
    columns img_id number path '/component/img/@id',
    img_id2 number path '/screw/img/@id'
    ) x
    And this is VERY SLOW :/
    select x.img_id, y.img_id
    from cfg_xml t
    , xmltable(
    '/revision/definitions/product/screw/img'
    passing T.EQ_CFG_XML
    columns img_id number path '@id'
    ) x,
    xmltable(
    '/revision/definitions/product/component/img'
    passing T.EQ_CFG_XML
    columns img_id number path '@id'
    ) y
    Is it possible to return al distinct ID in one column>?
    Thanks for HELP :)
    Edited by: kozand on 2011-06-29 07:50

  • Select distinct problem with muliple join tables, help needed

    Hi,
    I have two main tables. Each has its of sub joined tables.
    guest_id_for_reservation connects two major tables. This has
    to be that way
    because my guest may change the room status from single to
    double (and the
    similar exceptional requests).
    guests reservation
    guest_id_for_reservation
    countrytable hoteltable
    delegationtable roomtype
    I form a query. I want to select distinct those results. But
    it does not
    work.
    If I do not include any table related to reservation table
    and its sub
    joined tables (disregarding guest_id_for_reservation), it
    works.
    Is there a specific syntax for select distinct of this type
    or any
    workaround.?
    Thank you
    Hakan

    Hi I'm still battling with this - have connected the AX to my Imac via ethernet and it shows up fine in Airport Utility. Status light is green and it says its set up to connect to my existing wireless network using wireless connection. Security in Network Preferences is the same for both: WPA2 Personal.
    So I don't think there's a problem with the AX, and my current wireless network (BT Home Hub) is working fine.
    And when I restore factory settings Airport Utility can see the AX before updating settings so the wireless side of AX must work too.
    I'm figuring it must be something about the settings that mean AU can't see it anymore. But I can't work out what, since security is the same.
    Any ideas would be great!

  • Cm:select - howo to use distinct and such

    Hello:
    I need to do
    SELECT DISTINCT object_name FROM
    content
    How do I do that using cm:select?
    Is there a document anywhere that would explain the cm:select query
    language syntax?
    Any help is appreciated
    Thanks

    Hi Gennadiy,
    Unfortunately, what you want to do cannot be done via the cm:select tag, nor
    any of the standard public APIs. As was mentioned previously, if you were
    using the reference implementation, you could execute a SQL statement
    against the commercePool which looked like:
    SELECT DISTINCT AUTHOR FROM WLCS_DOCUMENT
    or:
    SELECT DISTINCT VALUE FROM WLCS_DOCUMENT_METADATA
    WHERE NAME = 'the name of the property you want'
    With Documentum, that obviously won't work. However, when you setup WLPS
    2.0.1 with Documentum, you configure a JDBC connection pool (dctmPool) that
    utilizes the Documentum JDBC driver. You can execute DQL select statements
    through this. Also, the Documentum Foundation Classes (DFC) are shipped
    with the Documentum WLPS integration piece, so those could be used.
    Questions related to how to use DQL or DFC should be directed to Documentum
    support.
    Regards,
    Ginny Peterson
    BEA Systems, Inc.
    "Gennadiy Civil" <[email protected]> wrote in message
    news:[email protected]...
    Thanks BUT --
    I did read the documentation and there is no way I could find to do what I
    need to do..
    I need to get a list of certain attributes from the content repository,not
    just from the arbitrary database.
    The documents in the repository have certain attributes - for example"autor"
    - so I need to get all the authors the documents have so I can buildbrowse by
    author drop down list.
    cm:select only allows me to get list of documents where for example author
    like "Asimov".
    So hence my question - how do I get a list of all possible non repeated
    authors from the repositiory.
    Thanks
    Gennadiy
    "néné" wrote:
    Hi Gennadiy,
    The <cm:select ...> tag is used to get information from the Content
    Management source.
    You can see the details of this tag at the following documentation URL:
    http://edocs.beasys.com/wlcs/p13ndev/jsptags.htm#1057716
    If you want to get info from the database, and want to use a SQL
    statement
    such as "SELECT DISTINCT object_name FROM ...", you should probably look
    into the <es:preparedstatement ...>
    tag.
    Check the documentation for the <cm:select ...> tag. There just mightbe
    enough info there to help you out!

  • Hash semi join and join selectivity

    Hi,
    I'm looking for an explanation of the rule-of-thumb that hash joins are more efficient for high selectivity joins.
    If I have a query with two tables, semi-joined together using an EXISTS clause, why would a hash join be better for a high selectivity join as opposed to a low selectivity join?
    To clarify, my definition of selectivity is:
    selectivity = # of rows returned / # of rows processed
    Or in more database specific terms:
    selectivity = num_rows/cardinality
    Selectivity is a value between 0 and 1, so by high selectivity, I mean a selectivity value closer to 1.
    Thanks for any input.
    - KR

    kenny r. wrote:
    Hi,
    I'm looking for an explanation of the rule-of-thumb that hash joins are more efficient for high selectivity joins.
    If I have a query with two tables, semi-joined together using an EXISTS clause, why would a hash join be better for a high selectivity join as opposed to a low selectivity join?
    To clarify, my definition of selectivity is:
    selectivity = # of rows returned / # of rows processed
    Or in more database specific terms:
    selectivity = num_rows/cardinality
    Selectivity is a value between 0 and 1, so by high selectivity, I mean a selectivity value closer to 1.KR,
    the question is "more efficient" than ... what?
    A hash join is usually the most efficient operation if you have to join a large set or two large sets. Often the hash join operation performs full table scans as part of the join operation, but not necessarily.
    The cost of the hash join depends on the volume to join, the available memory and the resulting operation (optimal / one-pass / multi-pass). If the hash table can be kept in memory then it's simply the cost to read the first data set used as hash table, the cost of reading the probe table and the CPU cost of processing the hash join. If the hash table doesn't fit into memory, it depends on how often the build (hash) table and probe data needs to be read (one-pass / multi-pass) to perform the join with the hash table.
    If you have a "low selectivity" join, and I assume you mean that the join actually filters out many rows by "low selectivity", then other join operations might be more effective, like a NESTED LOOP that uses the smaller table to iterate via an index access over the second table, selectively picking the rows corresponding to the first table. Depending on the number of iterations and the number of rows of the second table to process per iteration this can be very efficient, but tends to be very inefficient if the iterations and/or number of rows in second table is significantly larger than estimated.
    Regards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

Maybe you are looking for

  • Final cut dropped frames and image resolution

    I am working on a project involving placing a logo image over the video (simple). I have done this before with great results. I am trying the same with another project and I get warned that one or more dropped frames may have occured in playback. If

  • SVG problem in FF 2.0

    Some SVG charts are not correctly displayed in FF20. Wrong outputs in FF are like: "PIE:Chart 1Chart 1druga : 12%prva : 14%treća : 25%četvrta : 49% -" or "PIE:Popup Javni : 28.6%Apex Errors : 8.4%Pregled izdavatelja : 4.4%Kontakt : 3.9%e : 3.8%O agen

  • Transaction Logs in SQL Server

    Hi, the BW system has the following properties: BW 3.1C Patch 14 BASIS/ABA 6.20 Patch 38 BI_CONT 310 Patch 2 PI_BASIS Patch 2004_1_620 Windows 2000 Service Pack 4 SQL Server 2000 SP3 version 8.00.760 Database used space: 52 GB Database free space: 8.

  • Saving text messages if you're getting a new phone

    Is there a way to save text messages if I'm getting a new phone?

  • How to delay output in Java

    Hi, I have the following code in my program: output.println (" This is a test " ) ; When I run the program, the string, "This is a test", will be displayed on the screen at one time. However what I want is that the first char "T" is displayed first a