How to compare data cross 2 different tables in logical layer?

Hello
I have run into a situation where I need to bring in a new column from the status table say 'flag'. This physical column then needs to compare itself with the sales fact's code column. So if the code is '100' and above, then flag column should be '0', else flag.
In the data models, the sales fact joins to status dimension physically and logically.
So in the expression builder of the flag column in my BMM layer, I have something like *(case when Sales Mart. Sales Fact. status > '100' then '0' else Sales Mart. Sales Fact. flag end)*..
However, although the syntax is correct in the expression builder, however the logical column doesn't accept that expression via 'invalid expression'.
I think I know the problem, because flag column and status column are from different physical and logical column therefore it can't be used in the case statement at logical level. Because I tested this theory with '*(case when Sales Mart. Sales Fact. status > '100' then '0' end)'* and it accepted it.
Nonetheless, I can't modify the database table nor the ETL to put both columns in one table, nor am I allowed to defined such expression at answers.
Is there a way I can base the result of flag column on the data of status column from a different logical table?
Please advice!
Thanks

Follow these steps:
1) Bring your first time period in your main report.  This will be your first query.
2) Bring your second time period in a subreport.  This will be your second query.
3) Bring the values from your subreport into your main report using shared variables.
4) Lastly, compare the results using formulas in your main report.
I hope this information proves useful.
Regards,
Zack H.

Similar Messages

  • How to compare data from 2 different time periods

    Hi folks,
    I have a question on approach to a problem. I want to be able to compare data from a common db, but for 2 different time periods. For example I want to see the number of occurences of an instance in my data for today and compare it against occurences a week ago today. What's the best approach for this kind of problem? Is this done with 2 separate queries from 2 sub reports and then compared some how? Any comments on this approach or an other are appreciated.
    TIA bvd

    Follow these steps:
    1) Bring your first time period in your main report.  This will be your first query.
    2) Bring your second time period in a subreport.  This will be your second query.
    3) Bring the values from your subreport into your main report using shared variables.
    4) Lastly, compare the results using formulas in your main report.
    I hope this information proves useful.
    Regards,
    Zack H.

  • How to Compare Data length of staging table with base table definition

    Hi,
    I've two tables :staging table and base table.
    I'm getting data from flatfiles into staging table, as per requirement structure of staging table and base table(length of each and every column in staging table is 25% more to dump data without any errors) are different for ex :if we've city column with varchar length 40 in staging table it has 25 in base table.Once data is dumped into staging table I want to compare actual data length of each and every column in staging table with definition of base table(data_length for each and every column from all_tab_columns) and if any column differs length I need to update the corresponding row in staging table which also has a flag called err_length.
    so for this I'm using cursor c1 is select length(a.id),length(a.name)... from staging_table;
    cursor c2(name varchar2) is select data_length from all_tab_columns where table_name='BASE_TABLE' and column_name=name;
    But we're getting data atonce in first query whereas in second cursor I need to get each and every column and then compare with first ?
    Can anyone tell me how to get desired results?
    Thanks,
    Mahender.

    This is a shot in the dark but, take a look at this example below:
    SQL> DROP TABLE STAGING;
    Table dropped.
    SQL> DROP TABLE BASE;
    Table dropped.
    SQL> CREATE TABLE STAGING
      2  (
      3          ID              NUMBER
      4  ,       A               VARCHAR2(40)
      5  ,       B               VARCHAR2(40)
      6  ,       ERR_LENGTH      VARCHAR2(1)
      7  );
    Table created.
    SQL> CREATE TABLE BASE
      2  (
      3          ID      NUMBER
      4  ,       A       VARCHAR2(25)
      5  ,       B       VARCHAR2(25)
      6  );
    Table created.
    SQL> INSERT INTO STAGING VALUES (1,RPAD('X',26,'X'),RPAD('X',25,'X'),NULL);
    1 row created.
    SQL> INSERT INTO STAGING VALUES (2,RPAD('X',25,'X'),RPAD('X',26,'X'),NULL);
    1 row created.
    SQL> INSERT INTO STAGING VALUES (3,RPAD('X',25,'X'),RPAD('X',25,'X'),NULL);
    1 row created.
    SQL> COMMIT;
    Commit complete.
    SQL> SELECT * FROM STAGING;
            ID A                                        B                                        E
             1 XXXXXXXXXXXXXXXXXXXXXXXXXX               XXXXXXXXXXXXXXXXXXXXXXXXX
             2 XXXXXXXXXXXXXXXXXXXXXXXXX                XXXXXXXXXXXXXXXXXXXXXXXXXX
             3 XXXXXXXXXXXXXXXXXXXXXXXXX                XXXXXXXXXXXXXXXXXXXXXXXXX
    SQL> UPDATE  STAGING ST
      2  SET     ERR_LENGTH = 'Y'
      3  WHERE   EXISTS
      4          (
      5                  WITH    columns_in_staging AS
      6                  (
      7                          /* Retrieve all the columns names for the staging table with the exception of the primary key column
      8                           * and order them alphabetically.
      9                           */
    10                          SELECT  COLUMN_NAME
    11                          ,       ROW_NUMBER() OVER (ORDER BY COLUMN_NAME) RN
    12                          FROM    ALL_TAB_COLUMNS
    13                          WHERE   TABLE_NAME='STAGING'
    14                          AND     COLUMN_NAME != 'ID'
    15                          ORDER BY 1
    16                  ),      staging_unpivot AS
    17                  (
    18                          /* Using the columns_in_staging above UNPIVOT the result set so you get a record for each COLUMN value
    19                           * for each record. The DECODE performs the unpivot and it works if the decode specifies the columns
    20                           * in the same order as the ROW_NUMBER() function in columns_in_staging
    21                           */
    22                          SELECT  ID
    23                          ,       COLUMN_NAME
    24                          ,       DECODE
    25                                  (
    26                                          RN
    27                                  ,       1,A
    28                                  ,       2,B
    29                                  )  AS VAL
    30                          FROM            STAGING
    31                          CROSS JOIN      COLUMNS_IN_STAGING
    32                  )
    33                  /*      Only return IDs for records that have at least one column value that exceeds the length. */
    34                  SELECT  ID
    35                  FROM
    36                  (
    37                          /* Join the unpivoted staging table to the ALL_TAB_COLUMNS table on the column names. Here we perform
    38                           * the check to see if there are any differences in the length if so set a flag.
    39                           */
    40                          SELECT  STAGING_UNPIVOT.ID
    41                          ,       (CASE WHEN ATC.DATA_LENGTH < LENGTH(STAGING_UNPIVOT.VAL) THEN 'Y' END) AS ERR_LENGTH_A
    42                          ,       (CASE WHEN ATC.DATA_LENGTH < LENGTH(STAGING_UNPIVOT.VAL) THEN 'Y' END) AS ERR_LENGTH_B
    43                          FROM    STAGING_UNPIVOT
    44                          JOIN    ALL_TAB_COLUMNS ATC     ON ATC.COLUMN_NAME = STAGING_UNPIVOT.COLUMN_NAME
    45                          WHERE   ATC.TABLE_NAME='BASE'
    46                  )       A
    47                  WHERE   COALESCE(ERR_LENGTH_A,ERR_LENGTH_B) IS NOT NULL
    48                  AND     ST.ID = A.ID
    49          )
    50  /
    2 rows updated.
    SQL> SELECT * FROM STAGING;
            ID A                                        B                                        E
             1 XXXXXXXXXXXXXXXXXXXXXXXXXX               XXXXXXXXXXXXXXXXXXXXXXXXX                Y
             2 XXXXXXXXXXXXXXXXXXXXXXXXX                XXXXXXXXXXXXXXXXXXXXXXXXXX               Y
             3 XXXXXXXXXXXXXXXXXXXXXXXXX                XXXXXXXXXXXXXXXXXXXXXXXXXHopefully the comments make sense. If you have any questions please let me know.
    This assumes the column names are the same between the staging and base tables. In addition as you add more columns to this table you'll have to add more CASE statements to check the length and update the COALESCE check as necessary.
    Thanks!

  • How to compare data in a single table by month and year

    Hello Please.,
    i would like to see the 2014-06 matched results (3rd query),
    if the same ssn and acctno is exist in 2012-06 and 2013-06 and 2014-06 then eliminate from results, otherwise show it
    select ssn, acctno From jnj.drgSamples where Channel ='KM' and TrailMonth ='2012-06'
    select ssn, acctno From jnj.drgSamples where Channel ='KM' and TrailMonth ='2013-06'
    select ssn, acctno From jnj.drgSamples where Channel ='KM' and TrailMonth ='2014-06'
    i have written the below query but it shows only matched across three queries, but i want to display / delete from 2014-06 records if the ssn and acctno is exist in 2012-06 and 2013-06
    select c.*  from (
    (select * From jnj.drgSamples where Channel ='KM' and TrailMonth ='2012-06' ) a join
    (select * From jnj.drgSamples where Channel ='KM' and TrailMonth ='2013-06' ) b on a.SSN = b.SSN  and a.acctno = b.acctno  join
    (select * From jnj.drgSamples where Channel ='KM' and TrailMonth ='2014-06' ) C on a.SSN = c.SSN  and a.acctno = c.acctno  join
    Please Help me with this
    Thank you very much in Advance
    Asitti

    This is a relational division problem T-SQL:
    Relational Division
    Try:
    ;with cte as (select ssn, acctno, count (distinct(TrailMonth)) as cntMonths
    from jnj.drgSamples WHERE Channel = 'KM' AND TrailMonth IN ('2012-06','2013-06',2014-06'))
    GROUP BY ssn, acctno)
    delete from jnj.drgSamples S where exists (select 1 from cte where S.ssn = cte.ssn and S.acctno = cte.acctno and cte.cntMonths = 3)
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • How to compare two rows from two table with different data

    how to compare two rows from two table with different data
    e.g.
    Table 1
    ID   DESC
    1     aaa
    2     bbb
    3     ccc
    Table 2
    ID   DESC
    1     aaa
    2     xxx
    3     ccc
    Result
    2

    Create
    table tab1(ID
    int ,DE char(10))
    Create
    table tab2(ID
    int ,DE char(10))
    Insert
    into tab1 Values
    (1,'aaa')
    Insert
    into tab1  Values
    (2,'bbb')
    Insert
    into tab1 Values(3,'ccc')
    Insert
    into tab1 Values(4,'dfe')
    Insert
    into tab2 Values
    (1,'aaa')
    Insert
    into tab2  Values
    (2,'xx')
    Insert
    into tab2 Values(3,'ccc')
    Insert
    into tab2 Values(6,'wdr')
    SELECT 
    tab1.ID,tab2.ID
    As T2 from tab1
    FULL
    join tab2 on tab1.ID
    = tab2.ID  
    WHERE
    BINARY_CHECKSUM(tab1.ID,tab1.DE)
    <> BINARY_CHECKSUM(tab2.ID,tab2.DE)
    OR tab1.ID
    IS NULL
    OR 
    tab2.ID IS
    NULL
    ID column considered as a primary Key
    Apart from different record,Above query populate missing record in both tables.
    Result Set
    ID ID 
    2  2
    4 NULL
    NULL 6
    ganeshk

  • How to fill the data of two different tables into one?

    Hi Experts,
    I have two tables named CDHDR and CDSHW(structure). I have extracted the  data from these two tables through two function modules named CHANGEDDOCUMENT_HEADER and CHANGEDOCUMENT_POSITION. Now I have the data in to different tables.
    These two tables neither has relationship with each other through any field nor have any field which exist in both. Can anyone tell me in this case what should be the process to take the data of both the tables into one table. How can I match the record of one table to another?
    thanks a ton in advance.
    Edited by: Moni Bindal on Apr 28, 2008 4:16 PM
    Edited by: Alvaro Tejada Galindo on Apr 28, 2008 1:42 PM

    Hye Bindal,
      without a relation, it is not possible to club the data of 2 internal tables. More over it depends on the requirement as to y u should club to non related quantities in an internal table.
    if you wish to do so, one thing is it has internal table which includes the strucute of the 2.
    data: begin of ty_out,
              first type first_structure,
              second type second_structure,
             end of ty_out.
    data: itab type standard table of ty_out.
    data: wa type ty_out.
    loop into it1 into wa1.
    move corresponding wa to wa1.
    append wa to itab.
    endloop.
    loop into it2 into wa2.
    move corresponding wa to wa2.
    append wa to itab.
    endloop.
    now the internal table itab will have all the contents of it1 and it2.
    <REMOVED BY MODERATOR>
    Thanks,
    Imran.
    Edited by: Alvaro Tejada Galindo on Apr 28, 2008 1:43 PM

  • Can i use one interface to load data into 2 different tables

    Hi Folks,
    Can i use one interface to load data into 2 different tables(same schema or different schemas) from one source table with same structure ?
    Please give me advice
    Thanks
    Raj
    Edited by: user11410176 on Oct 21, 2009 9:55 AM

    Hi Lucky,
    Thanks for your reply,
    What iam trying is ...Iam trying to load the data from legacy tables(3) into oracle staging tables.But i need to load the same source data into two staging tables(these staging tables are in two different schemas)
    can i load this source data into two staging tables by using single standard interface(some business logic is there)
    If i can then give me some suggestion how to do that
    Thanks in advance
    Raj

  • How to export data from a Oracle table to a delimited file?

    I know how to load delimited file into a table, but how to export
    data from a Oracle table to a delimited file?
    Thanks in advance.

    Try looking at this link, it's long but there's three different solutions discussed in it. If you look at Barbara Boehmer's
    solution in her posts in the link below you'll see that she's addressed your concerns with spool files.
    Re: utl_smtp and triggers

  • How to do a SELECT from different tables into an internal table?

    How to do a SELECT from different tables into an internal table?
    I want to select data from MARA, MARC and ZPERSON and populate my ITAB_FINAL
    REPORT  zinternal_table.
    TABLES:
      mara,
      marc,
      zperson.
    TYPES:
    BEGIN OF str_table1,
      v_name LIKE zperson-zname,
      v_matnr LIKE marc-matnr,
      v_emarc LIKE marc-emarc,
      v_werks_d LIKE marc-werks_d,
      v_dstat LIKE marc-dstat,
      END OF str_table,
      i_table1 TYPE STANDARD TABLE OF str_table1.
    DATA:
    BEGIN OF str_table2,
    v_mandt LIKE mara-mandt,
    v_ernam LIKE mara-ernam,
      v_laeda LIKE mara-laeda,
    END OF str_table2,
    itab_final LIKE STANDARD TABLE OF str_table2.

    first find the link between mara , marc and zperson , if u have link to 3 tables then u can jus write a join and populate the table u want ( thats final table with all the fields).
    u defenitely have alink between mara and marc so join them and retrieve all data into one internal table.
    then for all the entries in that internal table retrieve data from zperson into another internal table.
    then loop at one internal table
    read another internal table where key equals in both the tables.
    finally assign fileds if sy-subrc = 0.
    gs_finaltable-matnr = gs_table-matnr
    etc...
    and finally append gs_finaltable to gt_finaltable.
    there u go ur final table has all the data u want.
    regards
    Edited by: BrightSide on Apr 2, 2009 3:49 PM

  • How to compare date and time together

    Hi,
    How to compare Date and Time together?
    For example in a database table there are two fields rundate and runtime.  I want to compare these two with perticular date and time in the program.  Like, I want to pull all the records where the records's date and time are less than a perticular date and time in the program.
    Hope the question is clear...
    Thanks.
    Kavita

    Hi Kavita
    There is no as such Date and Time Comparision FM in Standard SAP  But You can define your own like this
    <b>FUNCTION ZAV4_COMPAREDATETIME.
    ""Lokale Schnittstelle:
    *"  IMPORTING
    *"     REFERENCE(DATE1) TYPE  DATS
    *"     REFERENCE(TIME1) TYPE  TIMS
    *"     REFERENCE(DATE2) TYPE  DATS
    *"     REFERENCE(TIME2) TYPE  TIMS
    *"  EXPORTING
    *"     VALUE(TWOISMORETOPICAL) TYPE  C
      twoismoretopical = ''.
      if date2 > date1.
        twoismoretopical = 'X'.
      else.
         if date2 = date1 and time2 > time1.
           twoismoretopical = 'X'.
         endif.
      endif.
    ENDFUNCTION.</b>
    Regards
    Mithlesh

  • Stage tab delimited CSV file and load the data into a different table

    Hi,
    I pretty new to writing PL/SQL packages.
    We are using Application express for our development. We get CSV files which is stored as a BLOB content in a table. I need to write a trigger that would get executed once the user the uploads the file and parse thru the Blob content and upload or stage the data in a different table.
    I would like to see if there is any tutorial or article that could explain the above process with the example or sample code to do the same. Any help in this regard will be highly appreciated.

    Hi,
    This is slightly unusual but at the same time easy to solve. You can read through a blob using the dbms_lob package, which is one of the Oracle supplied packages. This is presumably the bit you are missing, as once you know how you read a lob the rest is programming 101.
    Alternatively, you could write the lob out to a file on the server using another built in package called utl_file. This file can be parsed using an appropriately defined external table. External tables are the easiest way of reading data from flat files, including csv.
    I say unusual because why are you loading a csv file into a blob? A clob is almost understandable but if you can load into a column in a table why not skip this bit and just load the data as it comes in straight into the right table?
    All of what I have described is documented functionality, assuming you are on 9i or greater. But you didn't provide a version so I can't provide a link to the documentation ;)
    HTH
    Chris

  • Selecting data from two different tables.

    Do we need to use join two tables with primary/foreign key while trying to use select statement for getting data from those to table.? If no who can i go about do it.

    872959 wrote:
    If i am using From clause to get data from two different tables, is it necessary that both tables have column of identical data in them.In general, they ought to (or you need to join in a third table that tells you how to map rows from one table to rows of the other table).
    It is not strictly necessary that there be any join condition between tables. If you don't provide a join condition, Oracle has to do a Cartesian product. That means that if there are n rows in one table and m rows in the other, the result set will have n * m rows. It is very rarely a good idea to write queries that do Cartesian products but it does occasionally happen.
    Justin

  • How to insert data into the mysql table by giving as a text file

    Hi,
    Any one know's how to insert data into the mysql table by giving as a text file as the input in JSP.Please respond ASAP.
    Thanks:)

    At least you can try StringTokenizer to parse your text files. Or download a text JDBC driver to parse your files, for instance, HXTT Text(www.hxtt.net) or StelsCSV(www.csv-jdbc.com).

  • How to move data from a staging table to three entity tables #2

    Environment: SQL Server 2008 R2
    I have a few questions:
    How would I prevent duplicate records, when/ IF SSIS is executed many times?
    How would I know that all huge volume of data being loaded in the entity tables?
    In reference to "how to move data from a staging table to three entity tables ", since I am loading large volume of data, while using lookup transformation:
    which of the merge components is best suited.
    How to configure merge component correctly. (screen shot is preferred) 
    Please refer to the following link
    http://social.msdn.microsoft.com/Forums/en-US/5f2128c8-3ddd-4455-9076-05fa1902a62a/how-to-move-data-from-a-staging-table-to-three-entity-tables?forum=sqlintegrationservices

    You can use RowCount transformation in the path where you want to capture record details. Then inside rowcount transformation pass a integer variable to get count value inside
    the event handler can be configured as below
    Inside Execute SQL task add INSERT statement to add rowcount to your audit table
    Can you also show me how to Check against destination table using key columns inside a lookup task and insert only non
    matched records (No Match output)
    This is explained clearly in below link which Arthur posted
    http://www.sqlis.com/sqlis/post/Get-all-from-Table-A-that-isnt-in-Table-B.aspx
    For large data I would prefer doing this in T-SQL. So what you could do is dump data to staging table and then apply
    T-SQL MERGE between tables (or even a combination of INSERT/UPDATE statements)
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to read data from an internal table into a real table?

    Hello experts,
    I'm relatively new to ABAP and I'm trying to figure out how to read data from an internal table into a table that I created.  I'm trying to use the RRW3_GET_QUERY_VIEW_DATA function module to read data from a multiprovider.  I'm trying to read data from the e_cell_data and e_axis_data tables into a table that I've already created.  Please see code below.
    TABLES MULTITAB.
    DATA:
      query_name TYPE RSZCOMPID,
      s_cubename TYPE RSINFOPROV,
      t_cell_data TYPE RRWS_T_CELL,
      t_axis_data TYPE RRWS_THX_AXIS_DATA,
      t_axis_info TYPE RRWS_THX_AXIS_INFO,
      wa_t_cell_data like line of t_cell_data,
      wa_t_axis_data like line of t_axis_data,
      w_corp_tab like line of t_cell_data.
    s_cubename = 'CORP_MPO1'.
    query_name = 'Z_corp_test'.
        CALL FUNCTION 'RRW3_GET_QUERY_VIEW_DATA'
           EXPORTING
             i_infoprovider           = s_cubename
             i_query                  = query_name
            i_t_parameter            = query_string_tab
           IMPORTING
             e_cell_data              = t_cell_data
             e_axis_data              = t_axis_data
             e_axis_info              = t_axis_info.
    If anyone has any information to help me, I would greatly appreciate it.  Thanks.

    Hi,
    <li>Once you call the function module RRW3_GET_QUERY_VIEW_DATA, lets say data is available in the corresponding tables e_cell_data e_axis_data which you have mentioned.
    <li>Modify your internal table defined for other purpose, with data from e_cell_data e_axis_data like below.
    LOOP AT t_cell_data INTO wa_t_cell_data.
      "Get the required data from t_cell_data.
      MOVE-CORRESPONDING wa_t_cell_data TO it_ur_tab.
      "Modify your internal table wih data
      MODIFY it_ur_tab TRANSPORTING <field1> <field2> <field3>.
    ENDLOOP.
    LOOP AT t_axis_data INTO wa_t_axis_data.
      "Get the required data from t_cell_data.
      MOVE-CORRESPONDING wa_t_axis_data TO it_ur_tab.
      "Modify your internal table wih data
      MODIFY it_ur_tab TRANSPORTING <field1> <field2> <field3>.
    ENDLOOP.
    Thanks
    Venkat.O

Maybe you are looking for

  • Storage location wise Opening/Closing Stock on posting date (mb5b)

    Hi, Report mb5b gives opening stock and closing stock as on date. In the selection screen, if we do not enter specific storage location then the opening/closing stock is displayed as sum of all storage location stocks for a given material. Where as i

  • Consuming web service in PHP

    Hello, I have a PHP page that consumes the web service from ABAP side. ABAP is definitely returning a table with a list of materials to the PHP page because we have set a remote breakpoint in the ABAP system and it is breaking at that particular poin

  • Event manager: relink missing file problem

    hello, lately I have been in this inmbattuto problems concerning the management of media and events, having worked on a project I was presented to the subsequent reopening of FCPX the classic yellow triangle on the event created by me: clicking with

  • How to change TreeModel into DefaultTreeModel?

    //This is my own TreeModel class: package xj.guieditor; import javax.swing.*; import javax.swing.event.*; import javax.swing.tree.*; import org.w3c.dom.*; import java.io.*; import java.util.*; import java.awt.*; import java.awt.event.*; * <p>Title: <

  • Problem with Oracle Intelligent Agent 8.1.7 Users Guide PDF

    I can't view of print certain pages (51,64,68) from the PDF version of the Oracle Intelligent Agent Release 8.1.7 User's Guide (http://downloadeast.oracle.com/docs/cd/A87860_01/doc/em.817/a85251.pdf). Have tried from several PCs and still get the err