Filter and Join on same table

Hi All,
I am having a bit of hard time, implementing following.
All suggestions welcome.
(1) I have a file being mapped into an initial table with say, 10 fields (field1...field10).
(2) I want to execute following logic for mapping
For all records in the table, in a cursor
If field1 = 10 Then
update field10=x
Else If field2 = 20 Then
update field10=y
End if
If field10=x then
update field3 =222
End if
I was thinking of using the filter, but am grappling with the problem that after I define the filter, how do I merge it with the original table data and execute the last conditional update (based on field10) on all records in the table?
- Am thinking of doing as below
Join the output from mother table with output from filter into a temp table (using non equal row id as the join condition), but this creates duplicate column names, and am wondering how to collapse them back into one column set again?
is there an alternative possible, for this is very kludgy (if it works at all).
Question 2
(1) I have a sql expression defined, which I want to use in the filter bifurcation and also after the join. The sql expression's input column and output columns are same, just the target are to be different?
Is it possible to do this, or do I have to duplicate the sql expression?
Question 3
My current load/stage is in PL/SQL procedure, which I am trying to model with OWB. Is there a guideline/ recommended best practice for doing this kind of activity?
Appreciate your help.
Deepak

1. I think I already gave an answer on this question (and there is one more of the same in the forum), but here it is again:
You can use an expression with a case statement:
CASE field1
WHEN 10 THEN 'x'
WHEN 20 THEN 'y'
WHEN ... THEN...
ELSE field10 END CASE
The input to this expression are fields field1 and field10, the output goes to field 10. So field10 will be updated with the value coming out of the expression - if field1 is 10 then it will be updated with 'x', when field1 is 20 then it will be updated with 'y' etc... when none of the CASE conditions are true (the ELSE case) it will be updated with the field10 (passt-hrough).
2. The best solution would be to create a transformation (a function, for example) that contains your expression, then use it throughout the project without having to retype it.
3. You should:
- Import the source object structures and (where possible) the target ones
- Design the new objects in OWB
- Import your custom transformation library, if there is one
- Design the extraction processes as mappings in OWB (you will not be able to reuse much of your old code if you want to take advantage of OWBs metadata management, runtime management etc. and if you want to maintain the system through OWB)
- Run the two systems side by side for some time until you are confortable that the process logic you designed in OWB gives the same results as the old process.
- Move the OWB system to production and switch the old system off.
Regards:
Igor

Similar Messages

  • Abap query, join between same tables

    Hi,
    I have an Abap Query (SQ01), I need to create a join between the same table (ESLL-ESLL) to obtain the services from a PO. The join is with the packno from ESLL to subpackno from ESLL (the same table). But I don't know how I can do that with Abap Query. Because the Infoset doesn't allow inserting the table two times.
    Somebody can help me.
    Thanks.
    Victoria

    Hi:
    I was able to create a query to retrieve the service lines entries using tables ESSR (Header) (service entry sheet number as input parameter), linked to package number to view ML_ESLL and then from the view the sup-package number linked to ESLL. That way I was able to retrieve all the service lines information from table ESLL only using SQ02 and SQ01, no ABAP.
    I Hope this help.
    Juan
    PS: I know the post is old but may be there are people out there with no ABAP access who needs to create reports for Service Entry Sheets lines. All the join conditions are.
    Table             Table
    ESSR            EKKO
    ESSR            ML_ESLL
    ML_ESLL      ESLL
    ESLL             ESLH
    Edited by: Juan Marino on Jan 23, 2012 10:53 PM

  • Reg. Particulare table export and import the same table

    Dear Sir
    I am MM consultant, I would like to export only one table and import the same after some request released,how to do this. Please help me.
    I am working in Oracle 10.2.0.2.0 release
    Thanks in advance
    Rajakumar.K

    Hello Raja,
    you want to export some table, perform some changes on the system (releasing a transport) and then reimport the old state of the table? This sounds like a very bad idea. You are inviting desaster and compromise the consistency of your system.
    Go to http://help.sap.com chose your release and enter the search term brspace to find out
    supported ways to reorganize a table.
    Regards,
    Mark

  • Need Help to provide Filter and Total Provisions for Table Control

    Hi ,
    I need to provide 'Set Filter' and 'Total(Summation)'  Buttons functionality in my application which is having a Table Control. I know these functionality provision with ALV Grid but not with Table control and would appreciate if any body can help me.
    Regards,
    Srinivas

    hi SRINI VASA
    can you provide me with the answer you found to your question, I'm having a spec with the similar requirement.
    Thanks

  • Insert and IMPDP on same table at a time

    Hi,
    We have table tableA, Which is around 20gb
    This table is subject to " ONLY INSERTS"
    Now I want to IMPDP the data (200gb) into same table with option of "TABLE_EXISTS_ACTION=APPEND" (Duplicates rows are allowed on column)
    The environment is OLTP so the new transactions (INSERTS only) will be happening into  this table while the IMPDP is in process.
    So kindly let me know whether it will affect the performance(because of two simultaneous insertion)???????
    Or it will take more time?????
    Kindly revert ........

    It is such a pity most people here
    - don't know how to use Google or refuse to use Google
    - don't know how to search the Forums
    - refuse to specify their four digit version number and platform info
    In general, treat a forum, an asynchronous communication mechanism, as a chatroom.
    Also I don't know what 'more time' means. Surely the classes in English in your locale are not that bad. 'More time' is meaningless.
    You are wasting more time by asking here than by trying in a test database.
    Sybrand Bakker
    Senior Oracle DBA

  • Left Outer Join on same table clarification

    HI,
    I have a table that gets populated from 3<sup>rd</sup> party system. We don’t have control over it. So, the table has master record (master) and children. Master type is 78 and children’s type is 64. So, it looks like this. In the 3<sup>rd</sup>
    party system, if Master transaction gets cancelled, it is recorded as type 178. If child is cancelled, then it is 164. Once the child is cancelled and created again using one process then newly created transaction will have 65 as type. Same thing with Master
    cancelled transaction also. It will be 79. So, to summarize:
    Master:                                                                                                                                                                      
    Brand New Transaction type = 78
    Cancelled Transaction type = 178
    Cancelled with creation transaction type = 79
    Child:
    Brand New Transaction type = 64
    Cancelled Transaction type = 164
    Cancelled with creation transaction type = 65
    I don’t have to bother about master records. I need to focus on only children for my query.
    ID
    TxnID
    Master
    Type
    TDate
    Location
    193075
    211554
    211543
    64
    20140805
    ABC
    193076
    211555
    211543
    64
    20140805
    NBC
    193077
    211556
    211543
    64
    20140805
    ABC
    193080
    211559
    211558
    64
    20140805
    ABC
    193081
    211562
    211561
    64
    20140805
    ABC
    193082
    211565
    211564
    64
    20140805
    CBC
    193083
    211565
    211564
    164
    20140805
    CBC
    193084
    211566
    211564
    65
    20140805
    AZC
    --drop
    table #Transactions
    CREATE
    TABLE #Transactions
    ID
    int,
    TxnID
    int,
    mstTicket
    int,
    Typecode
    int,
    Tdate
    datetime,
    Location
    varchar(10)
    select
    * from
    #Transactions
    Insert
    into #Transactions
    (ID,
    TxnID,
    mstTicket,Typecode,Tdate,Location)
    Select 193075, 211554,211543,64,'2014-08-05','ABC'
    UNION ALL
    Select 193076, 211555,211543, 64,
    '2014-08-05',
    'NBC' UNION ALL
    Select 193077, 211556, 211543, 64,
    '2014-08-05',
    'ABC' UNION
    ALL
    Select 193080, 211559, 211558, 64,
    '2014-08-05',
    'ABC' UNION
    ALL
    Select 193081, 211562, 211561, 64,
    '2014-08-05',
    'ABC' UNION
    ALL
    Select 193082, 211565, 211564, 64,
    '2014-08-05',
    'CBC' UNION
    ALL
    Select 193083, 211565, 211564, 164,
    '2014-08-05',
    'CBC' UNION
    ALL
    Select 193084, 211566, 211564, 65,
    '2014-08-05',
    'AZC'
    select
    T.TxnID,
    T.TypeCode,
    T.Location,
    TL.TxnID
    From
    #Transactions T
    Left Outer
    JOIN #Transactions
    TL ON
    TL.TxnID
    = T.TxnID
    and TL.TypeCode
    = 164
    select
    T.TxnID,
    T.TypeCode,
    T.Location,
    TL.TxnID
    From
    #Transactions T
    Left Outer
    JOIN #Transactions
    TL ON
    TL.TxnID
    = T.TxnID
    and TL.TypeCode
    = 164
    Where
    T.typecode
    in (64, 65)
    I need a clarification regarding left Outer Join. 
    In the first left outer join query both 64 and 164 both have TL.TxnID populated. Why is that?. What I understand from
    left outer join is that ‘Returns all the rows’ from left table and only matching data from right table.
    Here, matching row from right table is 211565 and 164 record (id 193083). So, only it should have TxnID populated. But row 211565 and 64 has TL.txnID getting populated (ID 193082).
    Why is it? Am I not understanding left out join properly?
    Thanks,

    Thank you Shailesh. I understood what join does in left outer join. I was thinking
     Left Outer JOIN #Transactions TL ON TL.TxnID = T.TxnID and TL.TypeCode = 164 is same as
    Left Outer JOIN #Transactions TL ON TL.TxnID = T.TxnID and TL.TypeCode = T.TypeCode
    and TL.TypeCode = 164
    #Transactions
    T
    Left
    Outer
    JOIN
    #Transactions
    TL
    ON
    TL.TxnID
    =
    T.TxnID
    and
    TL.TypeCode
    = 164
    Where
    T.typecode
    in
    (64,
    65)

  • Sql query with multiple joins to same table

    I have to write a query for a client to display business officers' names and title along with the business name
    The table looks like this
    AcctNumber
    OfficerTitle
    OfficerName
    RecKey
    90% of the businesses have exactly 4 officer records, although some have less and some have more.
    There is a separate table that has the AcctNumber, BusinessName about 30 other fields that I don’t need
    An individual account can have 30 or 40 records on the other table.
    The client wants to display 1 record per account.
    Initially I wrote a query to join the table to itself:
    Select A.OfficerTtitle, A.OfficerName, B.OfficerTitle, B.OfficerName, C.OfficerTtitle, C.OfficerName, D.OfficerTitle, D.OfficerName where A.AcctNumber = B.AcctNumber and A.AcctNumber = C.AcctNumber and A.AcctNumber = D.AcctNumber
    This returned tons of duplicate rows for each account ( number of records * number of records, I think)
    So added
    And A.RecKey > B.RecKey and B.RecKey > C. RecKey and C.RecKey . D.RecKey
    This works when there are exactly 4 records per account. If there are less than 4 records on the account it skips the account and if there are more than 4 records, it returns multiple rows.
    But when I try to l join this to the other table to get the business name, I get a row for every record on the other table
    I tried select distinct on the other table and the query runs for ever and never returns anything
    I tried outer joins and subqueries, but no luck so far. I was thinking maybe a subquery - if exists - because I don't know how many records there are on an account, but don't know how to structure that
    Any suggestions would be appreciated

    Welcome to the forum!
    user13319842 wrote:
    I have to write a query for a client to display business officers' names and title along with the business name
    The table looks like this
    AcctNumber
    OfficerTitle
    OfficerName
    RecKey
    90% of the businesses have exactly 4 officer records, although some have less and some have more.
    There is a separate table that has the AcctNumber, BusinessName about 30 other fields that I don’t need
    An individual account can have 30 or 40 records on the other table.
    The client wants to display 1 record per account.As someone has already mentioned, you should post CREATE TABLE and INSERT statements for both tables (relevant columns only). You don't have to post a lot of sample data. For example, you need to pick 1 out of 30 or 40 rows (max) for the same account, but it's almost certainly enough if you post only 3 or 4 rows (max) for an account.
    Also, post the results you want from the sample data that you post, and explain how you get those resutls from that data.
    Always say which version of Oracle you're using. This sounds like a PIVOT problem, and a new SELECT .... PIVOT feature was introduced in Oracle 11.1. If you're using Oracle 11, you don't want to have to learn the old way to do pivots. On the other hand, if you have Oracle 10, a solution that uses a new feature that you don't have won't help you.
    Whenever you have a question, please post CREATE TABLE and INSERT statements for some sample data, the results you want from that data, an explanation, and your Oracle version.
    Initially I wrote a query to join the table to itself:
    Select A.OfficerTtitle, A.OfficerName, B.OfficerTitle, B.OfficerName, C.OfficerTtitle, C.OfficerName, D.OfficerTitle, D.OfficerName where A.AcctNumber = B.AcctNumber and A.AcctNumber = C.AcctNumber and A.AcctNumber = D.AcctNumber Be careful, and post the exact code that you're running. The statement above can't be what you ran, because it doesn't have a FROM clause.
    This returned tons of duplicate rows for each account ( number of records * number of records, I think)
    So added
    And A.RecKey > B.RecKey and B.RecKey > C. RecKey and C.RecKey . D.RecKey
    This works when there are exactly 4 records per account. If there are less than 4 records on the account it skips the account and if there are more than 4 records, it returns multiple rows.
    But when I try to l join this to the other table to get the business name, I get a row for every record on the other table
    I tried select distinct on the other table and the query runs for ever and never returns anything
    I tried outer joins and subqueries, but no luck so far. I was thinking maybe a subquery - if exists - because I don't know how many records there are on an account, but don't know how to structure that
    Any suggestions would be appreciatedDisplaying 1 column from n rows as n columns on 1 row is called Pivoting . See the following link fro several ways to do pivots:
    SQL and PL/SQL FAQ
    Pivoting requires that you know exactly how many columns will be in the result set. If that number depends on the data in the table, then you might prefer to use String Aggregation , where the output consists of a huge string column, that contains the concatenation of the data from n rows. This big string can be formatted so that it looks like multiple columns. For different string aggregation techniques, see:
    http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php
    The following thread discusses some options for pivoting a variable number of columns:
    Re: Report count and sum from many rows into many columns

  • Where clause with XMLExists and join on another table

    Hi,
    We have table like:
    drop table xml_tbl;
    create table xml_tbl (
    xml_msg_id integer,
    xml_msg_text xmltype
    insert into xml_tbl values
    (1, '<main><id>1</id></main>') ;
    insert into xml_tbl values --(xml_msg_id,xml_msg_text)
    (1, '<main><id>2</id></main>') ;
    Another table like:
    create Table Table1
    ( id1 int);
    Insert into Table1 values(2);
    Insert into Table1 values(3);
    We need to have a view on top of the table xml_tbl where /main/id should have only those values which are in id1 column of table Table1.
    Something like
    CREATE OR REPLACE VIEW V_xml_tbl
    xml_msg_text
    AS
    SELECT T.xml_msg_text
    FROM xml_tbl T
    WHERE XMLEXISTS (
    'declare namespace Namesp1 ="Abc:Set";
    let $Results as xs:boolean := fn:exists($p/main/id in (Select id1 from Table1)) --Now here I know I can't do Select id1 from
    Table1*
    return if ($Results ) then true() else ()'
    PASSING T.xml_msg_text AS "p");
    Actually in the real scenario Table1 will have many IDs and xml_tbl has many XML files..
    So I am stuck on how to do it. Please help.
    Thanks..
    Edited by: user8941550 on Nov 20, 2012 7:19 PM

    One of these two :
    SQL> select t.xml_msg_text
      2  from xml_tbl t
      3  where exists (
      4    select null
      5    from table1 t1
      6    where t1.id1 = xmlcast(
      7                     xmlquery('/main/id' passing t.xml_msg_text returning content)
      8                     as integer
      9                   )
    10  );
    XML_MSG_TEXT
    <main>
      <id>2</id>
    </main>
    SQL> select t.xml_msg_text
      2  from xml_tbl t
      3     , xmltable('/main' passing t.xml_msg_text
      4         columns id integer path 'id'
      5       ) x
      6  where exists (
      7    select null
      8    from table1 t1
      9    where t1.id1 = x.id
    10  );
    XML_MSG_TEXT
    <main>
      <id>2</id>
    </main>
    And a third one, using XMLExists :
    SQL> select t.xml_msg_text
      2  from xml_tbl t
      3  where xmlexists (
      4    'fn:collection("oradb:/DEV/TABLE1")/ROW[ID1=$d/main/id]'
      5    passing t.xml_msg_text as "d"
      6  );
    XML_MSG_TEXT
    <main>
      <id>2</id>
    </main>
    Execution Plan
    Plan hash value: 3633580934
    | Id  | Operation           | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT    |         |     2 |   116 |     8   (0)| 00:00:01 |
    |*  1 |  FILTER             |         |       |       |            |          |
    |   2 |   TABLE ACCESS FULL | XML_TBL |     2 |   116 |     3   (0)| 00:00:01 |
    |   3 |   NESTED LOOPS      |         |     1 |     5 |     5   (0)| 00:00:01 |
    |   4 |    TABLE ACCESS FULL| TABLE1  |     2 |     6 |     3   (0)| 00:00:01 |
    |*  5 |    XPATH EVALUATION |         |       |       |            |          |
    Predicate Information (identified by operation id):
       1 - filter( EXISTS (SELECT 0 FROM "DEV"."TABLE1"
                  "SYS_ORAVW_2",XPATHTABLE('/main/id' PASSING :B1 COLUMNS "C_00$" XMLTYPE
                  PATH '.', "C_01$" XQEXVAL CHAR PATH '.')  "P" WHERE
                  TO_BINARY_DOUBLE("ID1")=TO_BINARY_DOUBLE("P"."C_01$")))
       5 - filter(TO_BINARY_DOUBLE("ID1")=TO_BINARY_DOUBLE("P"."C_01$"))The plan is similar to that of the second query above (XMLTable/EXISTS).
    Still using XMLExists, a plan similar to the first query (EXISTS/XMLCast/XMLQuery) can be achieved by casting id to an integer datatype :
    SQL> select t.xml_msg_text
      2  from xml_tbl t
      3  where xmlexists (
      4    'fn:collection("oradb:/DEV/TABLE1")/ROW[ID1=xs:int($d/main/id)]'
      5    passing t.xml_msg_text as "d"
      6  );
    XML_MSG_TEXT
    <main>
      <id>2</id>
    </main>
    Execution Plan
    Plan hash value: 1149640166
    | Id  | Operation          | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT   |         |     1 |    61 |     7  (15)| 00:00:01 |
    |*  1 |  HASH JOIN SEMI    |         |     1 |    61 |     7  (15)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| XML_TBL |     2 |   116 |     3   (0)| 00:00:01 |
    |   3 |   TABLE ACCESS FULL| TABLE1  |     2 |     6 |     3   (0)| 00:00:01 |
    Predicate Information (identified by operation id):
       1 - access("ID1"=SYS_XQ_ATOMCNVCHK(TO_NUMBER(SYS_XQ_UPKXML2SQL(SYS_XQ
                  EXVAL(SYS_XQEXTRACT(SYS_MAKEXML(0,"T"."SYS_NC00003$"),'/main/id'),1,50,3
                  3792,8192),50,1,0)),2,37))
    Note
       - Unoptimized XML construct detected (enable XMLOptimizationCheck for more information)Check each one on your real scenario to see which show best performance.
    (I would tend to say the ones involving streaming evaluation)
    Edited by: odie_63 on 5 nov. 2012 12:24
    Edited by: odie_63 on 5 nov. 2012 12:38

  • Dynamic Table - Add rows and columns in same table

    Hi there,
    I wonder if someone could help please? I'm trying to create and table where a user can add both rows and columns (preferably with separate buttons) but am having trouble trying to figure out how to do this. Is it possible? If so how? I'm not familar with script but have found examples of seprate tables where you can add a row and then another table where you can add columns and essentailly want to merge the two but cannot make it work.
    Any help much appreciated!
    Thanks,
    Ken

    It is great example....you can learn the concepts there and apply....however you may have to think twice before you implement column adding dynamically....because the technique here is make copy of what we already have and reproduce it as a new item and this technique works great for rows as they all have every thing in common. But when it comes to columns it may have unique visible identity as column head and displaying repeatedly the same column head may not look good. Of-Course you can do few extra lines of code and change the column appearance based on users input each time. Situations where users need to add additional column is very unlikely (sure your requirement might be an exception).
    Key in allowing adding/removing instances is managing design mode settings under Object>>Binding>>....and select the checkbox "Repeat <subform/row/...> for Each Data Item" and then set Min, Max and Initial count values.
    Also you need to club your effots by using simple scipt with button clicks....
    for the example refered in URL you posted following is what I did to make the first table allow Adding/Removing Rows....
    1. Opened the form in LC designer.
    2. Add two buttons AddRow & RemoveRow right next to RemoveColumn
    3. For AddRow I used following JS code....
          Table1._Row1.addInstance(1);//that means any time this button is clicked a new instance of Row1 is added use _Row2 or Row3 based on your needs
          var fVersion = new Number(xfa.host.version); // this will be a floating point number like "7.05"
          if (fVersion < 8.0) // do this for Acrobat versions earlier than 8.0
           // make sure that the new instance is properly rendered
           xfa.layout.relayout();
    4.  For RemoveRow I used following JS code....
         Table1._Row1.removeInstance(1);//Syntax is...<objectReference>.removeInstance(<index of the repeating object that needs to be removed>); //in this case since we used 1 alwasys second object from top gets deleted.
          var fVersion = new Number(xfa.host.version); // this will be a floating point number like "7.05"
          if (fVersion < 8.0) // do this for Acrobat versions earlier than 8.0
           // make sure that the new instance is properly rendered
           xfa.layout.relayout();
    5. Now time to update settings at Object>>Binding tab and set "Repeat......" and also set Min, Max and Initial count as explained above.
         Those settings needs to be updated for Row1 (or your choice of row) of the table
    6. Set the Height to Expand of the Subform, where the table is housed....  this is done under Layout pallet
    7. Save the PDF as dynamic template and verify the results...
    If you still run into issues I can send you copy that works on my machine, but you need send me an email at n_varma(AT)lycos.com
    Good luck,

  • Outer/Cartesian Join using same table

    Hi All,
    I'm needing to write a query, which is kind of like an outer join/cartesian join that essentially tags each customer in my database with a flag indicating whether they have received a particular product for a given year. There are 8 products so for each distinct customer_id in my database I want 8 records, with a 'Yes' or 'No' indicating whether they have received this product or not. Currently, for a given year, if a customer only receives 2 out of the 8 products there will be two records for that individual but I want 8 records for each individual so that each product is shown to either have been received or not received by the customer. This is the table format I'm looking for:
    CUSTOMER_ID     PRODUCT_CD     PRODUCT_RECEIVED_FLAG     YEAR
    999999999     1     Y     2010
    999999999     2     N     2010
    999999999     3     N     2010
    999999999     4     N     2010
    999999999     5     N     2010
    999999999     6     N     2010
    999999999     7     Y     2010
    999999999     8     Y     2010
    888888888     1     N     2010
    888888888     2     N     2010
    888888888     3     Y     2010
    888888888     4     Y     2010
    888888888     5     N     2010
    888888888     6     N     2010
    888888888     7     Y     2010
    888888888     8     Y     2010
    777777777     1     Y     2010
    777777777     2     Y     2010
    777777777     3     Y     2010
    777777777     4     Y     2010
    777777777     5     Y     2010
    777777777     6     Y     2010
    777777777     7     N     2010
    777777777     8     N     2010Thanks,
    Ed

    I am in good mood today ;) :
    with customer as (
                      select '999999999' customer_id from dual union all
                      select '888888888' from dual union all
                      select '777777777' from dual
          product as (
                      select level product_cd from dual connect by level <= 8
           orders as (
                      select '999999999' customer_id,1 product_cd,2010 year from dual union all
                      select '999999999',7,2010 from dual union all
                      select '999999999',8,2010 from dual union all
                      select '888888888',3,2010 from dual union all
                      select '888888888',4,2010 from dual union all
                      select '888888888',7,2010 from dual union all
                      select '888888888',8,2010 from dual union all
                      select '777777777',1,2010 from dual union all
                      select '777777777',2,2010 from dual union all
                      select '777777777',3,2010 from dual union all
                      select '777777777',4,2010 from dual union all
                      select '777777777',5,2010 from dual union all
                      select '777777777',6,2010 from dual union all
                      select '777777777',7,2010 from dual union all
                      select '777777777',8,2010 from dual
    -- end of on-the-fly data sample
    select  c.customer_id,
            p.product_cd,
            nvl2(o.product_cd,'Y','N') product_received_flag,
            y.year
      from       customer c
            cross join
                 product p
            cross join
                 select  distinct year
                   from  orders
                ) y
            left join
                orders o
              on (
                      c.customer_id = o.customer_id
                  and
                      p.product_cd = o.product_cd
                  and
                      y.year = o.year
      order by y.year,
               c.customer_id desc,
               p.product_cd
    CUSTOMER_ PRODUCT_CD P       YEAR
    999999999          1 Y       2010
    999999999          2 N       2010
    999999999          3 N       2010
    999999999          4 N       2010
    999999999          5 N       2010
    999999999          6 N       2010
    999999999          7 Y       2010
    999999999          8 Y       2010
    888888888          1 N       2010
    888888888          2 N       2010
    888888888          3 Y       2010
    CUSTOMER_ PRODUCT_CD P       YEAR
    888888888          4 Y       2010
    888888888          5 N       2010
    888888888          6 N       2010
    888888888          7 Y       2010
    888888888          8 Y       2010
    777777777          1 Y       2010
    777777777          2 Y       2010
    777777777          3 Y       2010
    777777777          4 Y       2010
    777777777          5 Y       2010
    777777777          6 Y       2010
    CUSTOMER_ PRODUCT_CD P       YEAR
    777777777          7 Y       2010
    777777777          8 Y       2010
    24 rows selected.
    SQL> SY.
    P.S. Code assumes at least one customer ordered at least one product within each year. Otherwise you will need year table.
    Edited by: Solomon Yakobson on Oct 28, 2011 2:36 PM

  • WAD 3.5 URL - Command Sequence Filter and set_hierarchy_state in same url

    Hey folks,
    i need your help with following command sequence:
    The Filter command works perfekt, but the second command 'set_hierarchy_state' doesnt work. I really tried everything, read blogs and how-to's...  please help me out:
    &CMD=LDOC&TEMPLATE_ID=KPAS_TEST&FILTER_IOBJNM=0DISTR_CHAN&FILTER_VALUE=30
    &FILTER_COLLAPSE=&FILTER_SIGN=E%26CMD_1%3DCMD%3DSet_Hierarchy_State%26
    DATA_PROVIDER%3DSFS_INTEC%26IOBJNM%3D0DISTR_CHAN%26HIERARCHY_NAME%3D
    AP_IP_FS_GESIPA%26ACTIVE%3DX
    This command works:
    &CMD=LDOC&TEMPLATE_ID=KPAS_TEST&CMD_1=CMD%3DSet_Hierarchy_State
    %26DATA_PROVIDER%3DSFS_INTEC%26IOBJNM%3D0DISTR_CHAN%26ACTIVE%3DX
    and this works:
    &CMD=LDOC&TEMPLATE_ID=KPAS_TEST&FILTER_IOBJNM=0DISTR_CHAN
    &FILTER_VALUE=30&FILTER_SIGN=E&FILTER_COLLAPSE=
    but i need the combination of both single commands

    Hi..
    I solved my own problem..
    that's the command sequence that works:
    &CMD_1=DATA_PROVIDER%3DSFS_LOCHER%26FILTER_IOBJNM
    %3D0DISTR_CHAN%26FILTER_VALUE%3D30%26FILTER_SIGN%3DE
    %26FILTER_COLLAPSE%3D&CMD_2=DATA_PROVIDER%3DSFS_GRUPPE
    %26FILTER_IOBJNM%3D0DISTR_CHAN%26FILTER_VALUE%3D30
    %26FILTER_SIGN%3DE%26FILTER_COLLAPSE%3D
    &CMD_3=CMD%3DSet_Hierarchy%26DATA_PROVIDER%3DSFS_INTEC
    %26MULTI%3DX%26IOBJNM%3D0DISTR_CHAN
    %26HIERARCHY_NAME%3DAP_IP_FS_GESIPA%26ACTIVE%3DX

  • Need Query - join in same table

    I need query for following criteria,
    Table : test
    No     Order
    1     a
    1     b
    1     c
    2     a
    2     b
    2     d
    3     e
    3     f
    3     g
    3     h
    1     f
    2     f
    Consider the above table,
    1)     I will give input order as a,b: It should return No 1,2
    No     Order
    1     a
    1     b
    1     c
    2     a
    2     b
    2     d
    3     e
    3     f
    3     g
    3     h
    1     f
    2     f
    2)     I will give input order as f,g,h: It should return No 3
    No     Order
    1     a
    1     b
    1     c
    2     a
    2     b
    2     d
    3     e
    3     f
    3     g
    3     h
    1     f
    2     f
    Please give me the query which will give above result.
    Thanks

    I am not sure I understand you, but it may be this
    with test as (
    select 1 N, 'a' Ord from dual union all
    select 1,'b' from dual union all
    select 1,'c' from dual union all
    select 2,'a' from dual union all
    select 2,'b' from dual union all
    select 2,'d' from dual union all
    select 3,'e' from dual union all
    select 3,'f' from dual union all
    select 3,'g' from dual union all
    select 3,'h' from dual union all
    select 1,'f' from dual union all
    select 2,'f' from dual )
    select N from test tp where Ord = 'a'
    intersect
    select N from test tp where Ord = 'b';
    with test as (
    select 1 N, 'a' Ord from dual union all
    select 1,'b' from dual union all
    select 1,'c' from dual union all
    select 2,'a' from dual union all
    select 2,'b' from dual union all
    select 2,'d' from dual union all
    select 3,'e' from dual union all
    select 3,'f' from dual union all
    select 3,'g' from dual union all
    select 3,'h' from dual union all
    select 1,'f' from dual union all
    select 2,'f' from dual )
    select N from test tp where Ord = 'f'
    intersect
    select N from test tp where Ord = 'g'
    intersect
    select N from test tp where Ord = 'h';

  • Modify table data and import to same bapi function module

    Hai friends,
    I have a requirement on bapi , such that after executing the bapi function module data comes on tables and again  i need enter  weight in weight column field in the same table data and pass the same table in the same bapi function module .
    plz sujjest.
    with reagards,
    prasad.

    Can  u explain in details,
    means which bapi r u using? where  u will enter weight? etc.

  • Join between 2 tables

    All,
    I am newbie to this forum.
    A main query has a table say A along with other tables in a query. My requirement is to add a new table say D to fetch the records in the below fashion...
    take grant_num from table A and join grant_num with table D and take deu_grant_num from same table D...Pass deu_grant_num from table D to table A and fetch the results with respect to the grant_num from table A...
    Below are the table structures:
    table A:
    User_id, grant_num,...
    Table B:
    grant_num, deu_grant_num, user_id...
    Appreciate ur help ASAP...

    Try This Query
    cursor abc is select grant_num from tableA
    where grant_num in(select grant_num from tableB
    where tableA.grant_num =tableB.grant_num)
    begin
    open abc;
    ftech abc into :grant_num ;
    close abc;
    end;
    or
    select grant_num into grant_num from tableA
    where grant_num in(select grant_num from tableB
    where tableA.grant_num =tableB.grant_num)

  • Multiple rows Converge to Single row and join

    Hi Folks,
    I am facing a tricky challenge to join a table with multiple rows and converge into a single row (based on ID, period) and join with another table to get a single row. Let me explain.
    Table 1: DTL_TABLE (id, period, course, names, title, type)
    1 2010 mat john null null
    1 2010 mat jim null null
    1 2010 cam null officer null
    1 2010 cam null Prof null
    1 2010 phy null null Inclass
    1 2010 phy null null Online
    Join with
    Table 2: ID_TABLE(id, period, Loc, Dept, Code)
    1 2010 nj 101 CC.
    Output format (id, period, course, names, title, type, Loc, Dept, Code)
    result : 1 2010 mat,cam,phy john,jim officer,prof inclass,online nj 101 CC
    I have created all the DDLs and DMLs if that help. Kindly let me know if a Join SQL query is possible.
    Thank you,
    Aj
    CREATE TABLE DTL_TABLE
       ids      VARCHAR2 (10),
       period   VARCHAR2 (10),
       course   VARCHAR2 (10),
       names    VARCHAR2 (10),
       title    VARCHAR2 (10),
       TYPE     VARCHAR2 (10)
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'mat',
                 'jim',
                 NULL,
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'mat',
                 'john',
                 NULL,
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'mat',
                 'kale',
                 NULL,
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'cam',
                 NULL,
                 'officer',
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'cam',
                 NULL,
                 'prof',
                 NULL);
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'phy',
                 NULL,
                 NULL,
                 'inclass');
    INSERT INTO DTL_TABLE
         VALUES ('1',
                 '2010',
                 'phy',
                 NULL,
                 NULL,
                 'online');
    COMMIT;
    CREATE TABLE id_table
       ids      VARCHAR2 (10),
       period   VARCHAR2 (10),
       loc      VARCHAR2 (10),
       dept     VARCHAR2 (10),
       code     VARCHAR2 (10)
    INSERT INTO id_table
         VALUES ('1',
                 '2010',
                 'nj',
                 '101',
                 'cc');
    COMMIT;

    Aj09 wrote:
    Hi Folks,
    I am facing a tricky challenge to join a table with multiple rows and converge into a single row (based on ID, period) and join with another table to get a single row. Let me explain.
    Table 1: DTL_TABLE (id, period, course, names, title, type)
    1 2010 mat john null null
    1 2010 mat jim null null
    1 2010 cam null officer null
    1 2010 cam null Prof null
    1 2010 phy null null Inclass
    1 2010 phy null null Online
    Join with
    Table 2: ID_TABLE(id, period, Loc, Dept, Code)
    1 2010 nj 101 CC.
    Output format (id, period, course, names, title, type, Loc, Dept, Code)
    result : 1 2010 mat,cam,phy john,jim officer,prof inclass,online nj 101 CC
    I have created all the DDLs and DMLs if that help. Kindly let me know if a Join SQL query is possible.
    SELECT TBL.id,
           DTLperiod,
           course,
           names,
           title,
           TYPE,
           Loc,
           Dept,
           Code
    FROM   ID_TABLE TBL,
           DTL_TABLE DTL
    WHERE  TBL.ID = DTL.ID
           AND TBL.PERIOD = DTL.PERIOD; it not good to use RESERVED WORDS like "ID" or "TYPE" as column names

Maybe you are looking for