Navigating from a UNION Query

I have a report (say Report1) where five queries are UNIONed together to give a result set. I have a navigation on one particular column (say Customer ID) for navigating to a different report (Report2) where Customer ID IS PROMPTED in Report2. But when I click on Customer ID = A11 in Report1, it takes me to Report2 but shows all rows whereas I expect only the rows corresponding to Customer ID A11. To verify the behavior, I created another report (Report3) wherein I had five UNION queries and this feature works fine in the new report. Report1 and Report3 are similar in design but Report3 is much smaller and simpler than Report1. Is there anything I can do to make this thing work in the report. It would take a lot of time recreate the report from scratch. Thanks.

I figured it out. Navigation does not work in Pivot Table. So, if you click on a customer name in the Pivot Table view, and the customer name is "Is Prompted" in the target report, the filter value will not be applied in the target report.

Similar Messages

  • Calculate total from a Union query

    Hi
    I want to UNION 3 query and need to create a total column. Below My table
    ID    Date           NoofVisit
    1    4/21/2014    1
    1    4/22/2014    1
    1    4/23/2014    1
    1    4/24/2014    1
    Another query
    ID    Date           NoofVisit
    1    4/21/2014    2
    1    4/24/2014    1
    1    4/26/2014    1
    Another query
    ID    Date           NoofVisit
    1    4/22/2014    2
    1    4/26/2014    1
    1    4/28/2014    1
    My query is below
    SELECT Id, Date, NoofVisit
    FROM dbo.vw_MO_All_FirstVisit
    UNION
    SELECT Id, Date, NoofVisit
    FROM vw_MO_All_SecondVisit
    UNION
    SELECT Id, Date, Noofvisit
    FROM vw_MO_All_ThirdVisit
    The result is
    ID    Date           NoofVisit
    1    4/21/2014    1
    1    4/22/2014    1                      Its should be 3
    1    4/23/2014    1
    1    4/24/2014    1                     Its should be 2
    1    4/26/2014    1                     Its should be 2
    1    4/28/2014    1
    Now what should the query is?
    Please help.
    Thanks in advance

    You can also get this output using JOIN
    SELECT COALESCE(t1.ID,t2.ID,t3.ID) AS ID,
    COALESCE(t1.[Date],t2.[Date],t3.[Date]) AS [Date],
    COALESCE(t1.NoOfVisit,0) + COALESCE(t2.NoOfVisit,0) + COALESCE(t3.NoOfVisit,0) AS TotalVisits
    FROM dbo.vw_MO_All_FirstVisit t1
    FULL JOIN dbo.vw_MO_All_SecondVisit t2
    ON t2.ID = t1.ID
    AND t2.[Date] = t1.[Date]
    FULL JOIN dbo.vw_MO_All_ThirdVisit t3
    ON t3.ID = t1.ID
    AND t3.[Date] = t1.[Date]
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • Need help in restricting a result set from a UNION in MERGE

    Hello,
    Would really appreciate if anybody could help me out with the issue I am facing with the below statements (I am new to Oracle ):
    merge into table_name_1 p
    using
      select p_key, value_1, value_2
      from some_tables
      UNION
      select p_key, value_1, value_2
      from some_tables
      UNION
    )t
    on (p.p_key = t.p_key)
    when matched then
      update table_name_1 with value_1 and value_2
    when not matched then
      insert table_name_1 with p_key, value_1, value_2;
    Now, the union of all those selects gives me distinct values and it works most of the times but when I get values like below, the merge fails:
    p_key-----value_1-----value_2
    100-----25-----50
    100-----NULL-----50
    I browsed the net and understood the reason behind this: the result set becomes ambiguous and merge doesn't know which row to insert first and which one to update.
    Now, my requirement is: I could have any of the below scenario/result sets from the union and I need only 1 row per p_key -
    result_set_1
    p_key-----value_1-----value_2
    100-----25-----50 ***************need this row
    100-----NULL-----50
    100-----NULL-----NULL
    result_set_2
    p_key-----value_1-----value_2
    100-----25-----NULL ***************need this row
    100-----NULL-----NULL
    result_set_3
    p_key-----value_1-----value_2
    100-----25-----NULL ***************need this row (p_key = 100)
    100-----NULL-----NULL
    200-----NULL-----75 ***************need this row (p_key = 200)
    200-----NULL-----NULL
    300-----90-----95 ***************need this row (p_key = 300)
    So, I basically need a way to restrict the values that I will get from the UNION of all those selects to fit the requirement above, hope I was able to explain the issue I am facing.
    Any help would be greatly appreciated.
    Thanks,
    Dpunk

    In all cases the goal is to find an order by value that will make the row you want be first.
    The query I gave is calculating a priority for each row by adding up values showing whether each column is null or not null. The case statements check whether each column is null and need to be added up to give a total priority value.
    Value_1   Value_2   Priority
    Not Null  Not Null  2 + 1 = 3
    Not Null  Null      2 + 0 = 2
    Null      Not Null  0 + 1 = 1
    Null      Null      0 + 0 = 0
    The priority value ends up being a bitmap showing whether each value is null or not null. I think that reflects my mathematics background.
    Another way of getting the same result (suggested to me by your asking why it needs the "+") would be to use two CASE expressions as separate order by items:
    select p_key, value_1, value_2 from
    (select p_key, value_1, value_2, row_number() over
              (partition by p_key
               order by case when value_1 is null then 0 else 1 end DESC,
                        case when value_2 is null then 0 else 1 end DESC
              ) as rn
      from (your UNION query here)
    where rn = 1
    A third way is to use a more complex case statement:
    select p_key, value_1, value_2 from
    (select p_key, value_1, value_2, row_number() over
              (partition by p_key
               order by case when value_1 is NOT null and value_2 is NOT null then 1
                             when value_1 is NOT null and value_2 is     null then 2
                             when value_1 is     null and value_2 is NOT null then 3
                             when value_1 is     null and value_2 is     null then 4
                         end  ASC
              ) as rn
      from (your UNION query here)
    where rn = 1

  • Customised sub-total via UNION query - how to exclude from totals?

    Hi,
    I have a client requirement that a couple of companies have their own sub-total in a report, a treatment which applies to no other companies in their group.
    I have achieved this via a union all, but they also want a total of companies.
    Is there anyway to emulate a Grand Total, other than another union query such that the double count is not double counted?
    thanks for any ideas.
    Robert.

    only solution which i can think of is to create another union request for the grand total.. this way you wont add up your sub totals twice..

  • Unable to use Navigational Attr in the query ?

    Hi experts,
    We are using BEx 3.X.
    We have a report based on an infoset. We want to use some navigational attributes in the query and
    restrict the values of these attributes.
    But we are unable to use them as navigational attr. They are displayed as display attributes only.
    We are unable to restrict them. This is because the query is on Infoset.
    When i use the same navigational attr in a query based on a infocube, it is displaying as Navigational Attr.
    We are in BI 7 but using BEx 3.X.
    How to resolve this ?
    Regards,
    Nishuv.

    Hi,
    Master Data Read
    A simple master data read should be done using generic BI functionality in the update rules. Choose the
    option u201CMaster Data Attribute ofu201D in the update rule details for the selected characteristic and select an
    attribute by using the F4 help. With this setting, the value of the characteristic to be updated is read from the
    master data table of the specified characteristic.
    Characteristic Material is provided by the InfoSource.
    Characteristic Material Group is not provided by the InfoSource.
    Characteristic Material Group is an attribute of characteristic Material
    Therefore you can fill Material Group from the master data table of Material: Select the method Master Data
    Attribute from and Material as source.
    The generic master data read only works for characteristics that are available in the communication
    structure.
    For a more complex master data read or if the characteristic is not available in the communication structure,
    you have to implement the master data read yourself in a routine for the specific characteristic. If so, the
    function module RSAU_READ_MASTER_DATA should be used to read the master data.
    In Infoset u can use max 2 cubes......and Infoobjects 'N' number u can use.......
    Thanks/Tarak

  • Error with getAttribute( ) function, while navigating from parent to child

    Hi,
    I have been trying to develop a small project with two task flow(TF).
    Both the TF contains only one page.
    Both of my pages are made from different VO,s.
    from the Parent page (P1) if i select a row and navigate to Child Page (P2), i need to filter the result in P2 using the selected row in P1.
    From P1 when i selected a row and navigate to P2 by clicking a button, i have used a Bean to get the parameters from the selected row and Passed the same to TF2.
    I made an AMImpl method and binded it to P2, such that whenever my P2 render this AMImpl method will be executed.
    Inside the AMImpl method i am trying to run the VO query of P2 with new selected criteria from TF1 ie.P1.
    i also have few more functionalites in P2 like when i select a row and clicks on a button i will some some info on a pop-up for the corresponding selected row.
    When i run the page P2 individually,all works fine. But when i navigate from P1 to P2 none of the functions are working, i.e when i click on the button on P2 to see popup its showing that Attribute is Null in the selected row, even though the attribute is not null. After navigation in P2 this function getAttribute( ) is returning null. but when i run P2 individually the same function is returning all required fields without error.
    Actual AMimpl.java method code :
    RowKeySet selectedRows =
    Table.getSelectedRowKeys(); //Table is a "Rich Table" i declared outside the method and binded to my actual table on P2
    Iterator selectedRowsIterator =
    selectedRows.iterator();
    DCBindingContainer dc =
    (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry();
    DCIteratorBinding iterBinding =
    dc.findIteratorBinding("P2Iterator");
    RowSetIterator rowSetIterator = iterBinding.getRowSetIterator();
    Key selectedRowkey =
    (Key)((List)(selectedRowsIterator.next())).get(0);
    Row selectedRow = rowSetIterator.getRow(selectedRowkey);
    String parameter1ForCurrentRow =
    selectedRow.getAttribute("parameter1").toString(); // -->this particular line is returning null while navigating from P1 to P2, but the same line returns actual value if the run P2 individually
    Kindly guide me how to achieve this.
    Regards
    Siva

    Hi Timo
    thanks for your reply.
    The reason I am doing this is to avoid the numerous instances of VO2 (Child VO) that will get created for every row of VO1. (eg: 100 rows of Vo1 means 100 instances of VO2 created & executed ).
    I am trying to avoid that by Binding and executing the params to a single child VO instance, only on the click of a button.
    Please advise if my assumption about as many child instances of VO2 being created and executed is incorrect and ADFBC does some kind of Lazy instantiation / loading of the child VO until the point of execution of the UI code where it is bound to ?

  • Sum of columns in union query

    hi, i am using oracle 10g database..
    how to get the sum of column in union query ?
         select * from (select 100 records from dual), (select 50 available from dual)
    union
    select * from (select 200 records from dual), (select 150 available from dual)
    display should be like
                     records         available
                      100               50
                      200               150
    total            300               200thanks ...

    Peter vd Zwan wrote:
    try this:Grouping by records will not produce correct results:
    SQL> with a as
      2  (
      3  select * from (select 100 records from dual), (select 50 available from dual)
      4  union
      5  select * from (select 100 records from dual), (select 100 available from dual)
      6  union
      7  select * from (select 200 records from dual), (select 150 available from dual)
      8  )
      9  select
    10    case when grouping(records) = 0 then null else 'total' end tot
    11    ,sum(records)   records
    12    ,sum(available) available
    13  from
    14    a
    15  group by
    16  rollup (records)
    17  ;
    TOT      RECORDS  AVAILABLE
                 200        150
                 200        150
    total        400        300
    SQL> select  case grouping(rownum)
      2     when 1 then 'Total'
      3   end display,
      4          sum(records) records,
      5          sum(available) available
      6    from  (
      7            select * from (select 100 records from dual), (select 50 available from dual)
      8           union
      9            select * from (select 100 records from dual), (select 100 available from dual)
    10           union
    11            select * from (select 200 records from dual), (select 150 available from dual)
    12          )
    13    group by rollup(rownum)
    14  /
    DISPL    RECORDS  AVAILABLE
                 100         50
                 100        100
                 200        150
    Total        400        300
    SQL> SY.

  • Alphabetical fetching from an SQL Query

    Hello,
    When I fetch from the following query:
    v_sql := 'SELECT REFERENCE_NO, COMPANY_NAME
    FROM CONSULTANTS
    ORDER BY COMPANY_NAME';
    The company names are in alphabetical order
    Something like:
    A
    B
    C
    D
    etc..
    Z
    then AFTER the capital letters come the a, b c
    Z
    then
    a
    then
    b
    etc..
    Is there a way to have the lower case letters such as "a" come right after ALL the "A"s
    Then the b's come after the B's
    Thanks
    Doug

    SQL> select col from (
      2  select 'a' col from dual
      3  union all
      4  select 'b' from dual
      5  union all
      6  select 'd' from dual
      7  union all
      8  select 'C' from dual
      9  union all
    10  select 'B' from dual
    11  union all
    12  select 'A' from dual
    13  )
    14  /
    C
    a
    b
    d
    C
    B
    A
    6 rows selected.
    SQL> select col from (
      2  select 'a' col from dual
      3  union all
      4  select 'b' from dual
      5  union all
      6  select 'd' from dual
      7  union all
      8  select 'C' from dual
      9  union all
    10  select 'B' from dual
    11  union all
    12  select 'A' from dual
    13  )
    14  order by upper(col), col
    15  /
    C
    A
    a
    B
    b
    C
    d
    6 rows selected.Rgds.

  • Calling oracle function from Access passthrough query does not return list

    Thanks to the help I received in an earlier post I've created an oracle 10g function that returns a list after executing the sql it contains. It works in oracle, using sql developer.
    I need to have the list that it returns show up in MS Access via a passthrough query. It's not working so far. The connection string etc is ok, I'm able to use passthrough queries to run sql strings successfully. But when I try to call the function via the Access passthrough query at first nothing seems to happen (ie no list appears) and if I try to run it again, there is a odbc error 'call in progress. Current operation canceled'. There are only the three records in the table. I'm missing something, can anyone spot it?
    The passthrough query looks like this
    select * from fn_testvalues from dual
    Again that runs in oracle.
    To create the testing table and 2 functions see below.
    CREATE TABLE t_values (MyValue varchar2(10));
    Table created
    INSERT INTO t_values (
    SELECT 'Merced' c1 FROM dual UNION ALL
    SELECT 'Pixie' FROM dual UNION ALL
    SELECT '452' FROM dual);
    3 rows inserted
    CREATE OR REPLACE FUNCTION fn_isnum(p_val VARCHAR2) RETURN NUMBER IS
    n_val NUMBER;
    BEGIN
    n_val := to_number(p_val);
    RETURN 1;
    EXCEPTION
    WHEN OTHERS THEN
    RETURN 0;
    END;
    Function created
    testing the table:
    SELECT val, fn_isnum(MyValue ) isnum
    FROM t_values;
    VAL ISNUM
    Merced 0
    Pixie 0
    452 1
    Now the function that is called in the passthrough query:
    create or replace function fn_testvalues
    return sys_refcursor is
    rc sys_refcursor;
    begin
    open rc for
    Select t_values.*, fn_isnum(MyValue) IsNum from t_values;
    return(rc);
    end fn_testvalues;

    lecaro wrote:
    OK. But obviously there is some oracle object that one can call via an Access pass-through query which returns rows?Just to clarify. You could fetch data in Access from an Oracle function that returns a ref cursor using VBA editor. To use a pass-through query Oracle function should be a table function or pipelined table function:
    CREATE OR REPLACE
      TYPE testvalues_obj_type
        AS OBJECT(
                  val varchar2(10),
                  isnum number
    CREATE OR REPLACE
      TYPE testvalues_tbl_type
        AS TABLE OF testvalues_obj_type
    CREATE OR REPLACE
      FUNCTION fn_testvalues
        RETURN testvalues_tbl_type
        PIPELINED
        IS
            CURSOR testvalues_cur
              IS
                SELECT  testvalues_obj_type(MyValue,fn_isnum(MyValue)) testvalues_obj
                  FROM  t_values;
        BEGIN
            FOR v_rec IN testvalues_cur LOOP
              PIPE ROW(v_rec.testvalues_obj);
            END LOOP;
            RETURN;
    END;
    /To test it in Oracle:
    SELECT  *
      FROM  TABLE(fn_testvalues)
    VAL             ISNUM
    Merced              0
    Pixie               0
    452                 1
    SQL> Now in Access pass-trough query window enter:
    SELECT  *
      FROM  TABLE(fn_testvalues);SY.

  • How to get the number value from Oracle SQL Query?

    Hi All,
    I have a query which will return the below output.
    LINE_NUMBER           STRING
    10000                        A,B,C,D
    20000                       X,Y,Z,D
    80000                       P,Q,R,A
    130000                     E,R,T,Y
    210000                     Y,R,G,H
    1300000                   F,H,Y,UThe above output i need to get only the number 1, 2, 8, 13, 21, 210 for each row. Can you give the solution for that?
    Thanks

    Another wild guess
    SQL>  with t as (
    select '10000                        A,B,C,D' str from dual union all
    select '20000                       X,Y,Z,D' str from dual union all
    select '80000                       P,Q,R,A' str from dual union all
    select '130000                     E,R,T,Y' str from dual union all
    select '210000                     Y,R,G,H' str from dual union all
    select '1300000                   F,H,Y,U' str from dual
    select str, rtrim(regexp_substr(str,'\d+'),0) nums from t
    STR                                  NUMS                               
    10000                        A,B,C,D 1                                  
    20000                       X,Y,Z,D  2                                  
    80000                       P,Q,R,A  8                                  
    130000                     E,R,T,Y   13                                 
    210000                     Y,R,G,H   21                                 
    1300000                   F,H,Y,U    13                                 
    6 rows selected.

  • Prompts for Combine similar request (Union query)

    I have been given 5 tables for creating one report out of each table. I created aliases and
    necessary self joins. I now need a summaryreport that combines these five tables. I tried the
    "combine similar request" and the report functions fine. Now I have to create two prompts, one for
    country and one for job. These are fields available in 4 tables and have the same format alongwith
    the same datatypes. Please help me with this.
    Table 1 Report A
    Table 2 Report B
    Table 3 Report C
    Table 4 Report D
    Table 5 Report E
    Table 1 - Table 4 contains Country and Job field which is of the same format and datatype.
    Table 5 does not have these and its not necessary for us to prompt this.
    This has no star schema setup and I am not in a position to get it done as well. I considered each
    table to be a fact table and created aliases, selfjoins etc. Please help with the procedure to
    create the two dashboard prompts. If I choose USA then the first four amongst the union queries
    should reflect data for the USA. The same applies for Job.

    Hello
    Thanks for the reply.
    My problem here is that I have 5 different tables with country fields in them. They are of the same format and datatype but there is no join between these tables. If I choose one Country field from any particular table, then the combine similar request doesnt seem to take it for other queries where the fields come from a different table.
    eg.
    Table 1 - table 5 have country fields
    I choose to create a prompt based on Country from Table 1. The union query doesnt seem to reflect on filtering values on the queries from other tables. It would filter only the values from table 1.
    Please let me know as to what can be done!

  • Value disappearing while navigating from Page2 to Page1

    Hi Friends,
    Scenario: I am navigating from page1 to page2. While doing so am retaining the AM state. The problem is when i navigate from page2 to page1 the new values that i have entered in page1 disappears but the queries which i executed while loading page1 is retained and those values are displayed.
    I double checked whether i have executed/instantiated a query but its negative. Also i checked the row count of the view object, its giving the same count.
    Can u all please help me in resolving a solution?
    Thanks,
    KR
    Edited by: KR on Jun 3, 2013 11:01 PM

    Hi Sandeep,
    I have all protected all the VO execution with condition check.
    Since you have asked... i am posting my controller code for page1 below...
    public void processRequest(OAPageContext pageContext, OAWebBean webBean) {
    super.processRequest(pageContext, webBean);
    System.out.println("In PR : " + pageContext.getParameter(EVENT_PARAM));
    System.out.println(pageContext.getSessionId());
    OAFormValueBean awid = (OAFormValueBean)webBean.findChildRecursive("AwardHeaderId");
    String mode = pageContext.getParameter("mode");
    System.out.println("mode : "+mode);
    OAApplicationModule oaam = pageContext.getApplicationModule(webBean);
    String attach = (String)pageContext.getTransactionValue("add");
    System.out.println("Attach : " + attach);
    String tenderNumber =
    pageContext.getParameter("tendno");
    if (attach == null && "Create".equals(mode) && !"itemReturn".equals(mode)) {
    System.out.println("Inside attach");
    Serializable[] tenderNo = { tenderNumber };
    oaam.invokeMethod("executeTenderDetails", tenderNo);
    oaam.invokeMethod("executeAwardDetails", tenderNo);
    oaam.invokeMethod("initNotes");
    oaam.invokeMethod("executeNotesHistory", tenderNo);
    oaam.invokeMethod("initAttach");
    System.out.println("Awid : "+awid.getValue(pageContext));
    pageContext.removeTransactionValue("add");
    System.out.println("add Trans : "+pageContext.getTransactionValue("add"));
    System.out.println("End");
    OAViewObject vo = (OAViewObject)oaam.findViewObject("XxdmIcmAwardNotesHistVlVO1");
    System.out.println("Fetched RowCount : "+vo.getFetchedRowCount());
    In the if clause, i have checked *!("itemReturn".equals(mode))*.
    This condition fails because i have set mode to be itemReturn when navigating from page2 to page1.
    Thanks,
    KR

  • Alternative/enhancement to union query? Duplicate - please delete

    Hello,
    I have 2 sets of similar data which I am joining together with a union query.
    Simplified E.g.
    *Table A*
    Name Dept
    Ben    1
    Amy   3
    Ken    3
    *Table B*
    Name Dept
    Jim    1
    John  2
    Sue   3
    select Name, Dept
    from table A
    UNION
    select Name, Dept
    from table BWhat I would like to do is ONLY include data from the second part of the union query where it joins with some data from the first part of the union query.
    E.g.
    select Name, Dept
    from table A
    UNION
    select Name, Dept
    from table B
    where Dept in (select distinct Dept from A)Therefore John that works in Dept 2 would not be included in the results.
    Is there a better or more efficient way of doing this than my example using the subquery as part of the where clause?
    Many thanks,
    Hazel
    Edited by: user11979866 on 04-Nov-2010 08:48

    Hazel:
    It would really depend on the sizes of the tables and the indexes available, but that is probably the way I would write it, at least as a first cut.
    You could lose the distinct in the in sub-query since it is implied by the in itself, and Oracle will only return one row from the sub-query for each value of dept in A.
    John

  • Alternative/enhancement to union query?

    Hello,
    I have 2 sets of similar data which I am joining together with a union query.
    Simplified E.g.
    *Table A*
    Name Dept
    Ben    1
    Amy   3
    Ken    3
    *Table B*
    Name Dept
    Jim    1
    John  2
    Sue   3
    select Name, Dept
    from table A
    UNION
    select Name, Dept
    from table BWhat I would like to do is ONLY include data from the second part of the union query where it joins with some data from the first part of the union query.
    E.g.
    select Name, Dept
    from table A
    UNION
    select Name, Dept
    from table B
    where Dept in (select distinct Dept from A)Therefore John that works in Dept 2 would not be included in the results.
    Is there a better or more efficient way of doing this than my example using the subquery as part of the where clause?
    Many thanks,
    Hazel

    Hi, Hazel,
    What you posted is as good as you can get without changing the tables.
    You don't have to say DISTINCT in the IN-subquery:
    where   Dept in (  select  Dept
                       from    A
                    )will get the same results, perhaps a little faster.

  • Mapping relation from sap bw query to crystal report

    Hello Gurus,
            will you please describe mapping relation for following items from sap bw query to crystal report? it is better to provide a instance for each one.
               (1) character   (2) key figure  (3) navigation attribute  (4) display attribute (5) charater with hiararchy
    Many thanks

    This blog may be helpful:
    /people/ingo.hilgefort/blog/2008/10/03/businessobjects-and-sap-part-1-of-4--creating-a-xcelsius-dashboard-on-top-of-sap-bi

Maybe you are looking for