Distinct-values() in XQuery

According Q4, 1.1.9.4 in XML Query User Case and Oracle magazine (May2003), the function should be all right. Why the following XQuery can not be excuted in command line?
Error message:
XQE: unknown function 'distinct-values'
Thanks a lot!
<dataroot>
let $a := document("Orders.xml")/dataroot/Orders
for $o in distinct-values($a/CusomerID),
$c in document("Customers.xml")/dataroot/Customers
where $c/CustomerID = $o/CustomerID
return
<Customer>
{ $c/CustomerID }
{ $c/CustomerName }
</Customer>
</dataroot>

Hi,
Please let me know where It went wrong.The function's return value is declared as a string but you're actually returning sequences of string literals.
One way to achieve that is using string-join function :
(here for testing purpose, I used an external $doc variable)
declare namespace xf = "http://tempuri.org/abcorg/Transformations/Distinct_Fruits/";
declare default element namespace "http://www.abc.org.com/FormDetails";
declare function xf:Distinct_Fruits( $fruits as element(Fruits)* )
as xs:string
string-join(
   for $d in distinct-values($fruits/fruit/@name)
   return concat($d, " = ", $fruits/fruit[@name=$d][1]/@color)
, "|"
xf:Distinct_Fruits($doc/Main/Fruits)Note that I assumed that a fruit with a given name will always have the same color.
If that's not the case and you might have something like :
<Main>
<abcd first="1" second="2"/>
<Fruits>
  <fruit name="banana" color="green"/>
  <fruit name="apple" color="red"/>
  <fruit name="grape" color="green"/>
  <fruit name="apple" color="red"/>
  <!-- here is a red banana! -->
  <fruit name="banana" color="red"/>
  <fruit name="apple" color="red"/>
  <fruit name="grape" color="green"/>
  <fruit name="orange" color="orange"/>
  <fruit name ="lemon" color="yellow"/>
</Fruits>
</Main>then the solution is to use deep-equal function to test if two nodes are identical (as per their values, attributes and children) :
declare function xf:Distinct_Fruits( $fruits as element(Fruits) )
as xs:string
string-join(
   for $i in $fruits/fruit
   let $f := $i[not(some $x in $i/preceding-sibling::fruit satisfies fn:deep-equal($x,.))]
   where ($f)
   return concat($f/@name, " = ", $f/@color)
, "|"
};which gives :
banana = green|apple = red|grape = green|banana = red|orange = orange|lemon = yellowEdited by: odie_63 on 12 juil. 2011 14:43 - changed first example to reflect sample modification

Similar Messages

  • Retrieve Distinct Values using XQuery

    The following query is returning me duplicate rows. How can we retrieve the distinct values? Can we use Distinct somewhere in this query? Please help me.
    SELECT XMLQuery('<Update>
    { for $demo in (ora:view("TableA")),
    $demo_audit in ora:view("TableA_AUDIT")
    let $demo_id := $demo/ROW/ID/text(),
    $demo_audit_trans_date := $demo_audit/ROW/DATE/text(),
    $demo_audit_id := $demo_audit/ROW/ID/text(),
    $demo_audit_type := $demo_audit/ROW/TYPE/text()
    where $demo_id = $demo_audit_id and
    $demo_audit_type = "U"
    return
    <result>
    <type>U</type>
    <id>{$demo_id}</id>
    </result>}</Data>' RETURNING CONTENT)
    FROM dual;

    Geoff,
    I tried distinct-values in both let and return; however the result isn't distinct. Is the usage correct?
    SELECT XMLQuery('<Update>
    {for   $a in ora:view("EMP")
           let   $a_empno         := distinct-values($a/ROW/EMPNO/text()),
                 $a_ename         := $a/ROW/ENAME/text(),
                 $a_job           := $a/ROW/JOB/text(),
                 $a_mgr           := $a/ROW/MGR/text(),
                 $a_deptno        := distinct-values($a/ROW/DEPTNO/text())
           return
           <op>
                 <empno>{distinct-values($a_empno)}</empno>
    <name>{$a_ename}</name>
    <deptno>{distinct-values($a_deptno)}</deptno>
    </op>}
    </Update>'
    RETURNING CONTENT)
    FROM dual;
    The output generated is given below:
    <Update>
    <op>
    <empno>1</empno>
    <name>Henry</name>
    <deptno>10</deptno>
    </op>
    <op>
    <empno>1</empno>
    <name>Henry1</name>
    <deptno>10</deptno>
    </op>
    </Update>

  • Xquery to return distinct values in xml

    Hi,
    I have a requirement, where in i have to get distinct values from an xml file.
    EX: Input
    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    <Main xmlns="http://www.abc.org.com/FormDetails">
    <abcd first="1" second="2"/>
    <Fruits>
    <fruit name="banana" color="green">
    <fruit name="apple" color="red">
    <fruit name="grape" color="green">
    <fruit name="apple" color="red">
    <fruit name="banana" color="green">
    <fruit name="apple" color="red">
    <fruit name="grape" color="green">
    <fruit name="orange" color="orange">
    <fruit name ="lemon" color="yellow">
    </Fruits>
    <Fruits>
    <fruit name="banana" color="green">
    <fruit name="apple" color="red">
    <fruit name="grape" color="green">
    <fruit name="apple" color="red">
    <fruit name="banana" color="green">
    <fruit name="apple" color="red">
    <fruit name="grape" color="green">
    <fruit name="orange" color="orange">
    <fruit name ="lemon" color="yellow">
    </Fruits>
    <Fruits>
    <fruit name="banana" color="green">
    <fruit name="apple" color="red">
    <fruit name="grape" color="green">
    <fruit name="apple" color="red">
    <fruit name="banana" color="green">
    <fruit name="apple" color="red">
    <fruit name="grape" color="green">
    <fruit name="orange" color="orange">
    <fruit name ="lemon" color="yellow">
    </Fruits>
    </Main>
    Required output: String
    banana = green|apple = red| grape=green|orange=orange|lemon=yellow
    I have used this xquery:
    declare namespace xf = "http://tempuri.org/abcorg/Transformations/Distinct_Fruits/";
    declare namespace ns = "http://www.abc.org.com/FormDetails";
    declare function xf:Distinct_Fruits($fruits as element(ns:Main))
    as xs:string{
    for $d in distinct-values($fruits//ns:fruit/@name)
    return "{$d} ="
    for $e in distinct-values($fruits//ns:fruit/@color)
    return "{$e}|"
    declare variable $fruitsas element(ns:Main) external;
    xf:Distinct_Member($fruits)
    I am getting error like:
    Error executing the XQuery transformation: line 11, column 1: {err}FORG0005: expected exactly one item, got 2+ items
    Please let me know where It went wrong.
    Thanks..
    Edited by: user12679330 on Jul 12, 2011 4:47 AM

    Hi,
    Please let me know where It went wrong.The function's return value is declared as a string but you're actually returning sequences of string literals.
    One way to achieve that is using string-join function :
    (here for testing purpose, I used an external $doc variable)
    declare namespace xf = "http://tempuri.org/abcorg/Transformations/Distinct_Fruits/";
    declare default element namespace "http://www.abc.org.com/FormDetails";
    declare function xf:Distinct_Fruits( $fruits as element(Fruits)* )
    as xs:string
    string-join(
       for $d in distinct-values($fruits/fruit/@name)
       return concat($d, " = ", $fruits/fruit[@name=$d][1]/@color)
    , "|"
    xf:Distinct_Fruits($doc/Main/Fruits)Note that I assumed that a fruit with a given name will always have the same color.
    If that's not the case and you might have something like :
    <Main>
    <abcd first="1" second="2"/>
    <Fruits>
      <fruit name="banana" color="green"/>
      <fruit name="apple" color="red"/>
      <fruit name="grape" color="green"/>
      <fruit name="apple" color="red"/>
      <!-- here is a red banana! -->
      <fruit name="banana" color="red"/>
      <fruit name="apple" color="red"/>
      <fruit name="grape" color="green"/>
      <fruit name="orange" color="orange"/>
      <fruit name ="lemon" color="yellow"/>
    </Fruits>
    </Main>then the solution is to use deep-equal function to test if two nodes are identical (as per their values, attributes and children) :
    declare function xf:Distinct_Fruits( $fruits as element(Fruits) )
    as xs:string
    string-join(
       for $i in $fruits/fruit
       let $f := $i[not(some $x in $i/preceding-sibling::fruit satisfies fn:deep-equal($x,.))]
       where ($f)
       return concat($f/@name, " = ", $f/@color)
    , "|"
    };which gives :
    banana = green|apple = red|grape = green|banana = red|orange = orange|lemon = yellowEdited by: odie_63 on 12 juil. 2011 14:43 - changed first example to reflect sample modification

  • XQuery: Retrieve Distinct Values

    The following query is returning me duplicate rows. How can we retrieve the distinct values? Can we use Distinct somewhere in this query? Please help me.
    SELECT XMLQuery('<Update>
    { for $demo in (ora:view("TableA")),
    $demo_audit in ora:view("TableA_AUDIT")
    let $demo_id := $demo/ROW/ID/text(),
    $demo_audit_trans_date := $demo_audit/ROW/DATE/text(),
    $demo_audit_id := $demo_audit/ROW/ID/text(),
    $demo_audit_type := $demo_audit/ROW/TYPE/text()
    where $demo_id = $demo_audit_id and
    $demo_audit_type = "U"
    return
    <result>
    <type>U</type>
    <id>{$demo_id}</id>
    </result>}</Data>' RETURNING CONTENT)
    FROM dual;

    Playing the devil here...
    SELECT distinct XMLQuery...

  • How to get distinct values from a list and display in a ListView webpart.

    Hi,
    I have a requirement in which I need to pull unique/distinct values from a custom list and then display it via a listview webpart. Can any one suggest how this can be done.
    If possible please share the CAMEL query to fetch distinct values from a custom list.
    Thanks,
    Ankit

    Hi Ankit,
    Is there any particular reason that the values need to be shown in a list view web part?  Are you going to use that web part for filtering via web part connections?
    I ask because the enterprise site collection features include the SharePoint List Filter web part, which may accomplish what you're looking for.
    If you just need to display the values in a grid view, you might have more luck with the JavaScript Client Object Model.  Try putting the following in a text file:
    <style>
    .CustomTableClass{display:table;table-layout:fixed}
    .CustomRowClass{display:table-row;}
    </style>
    <div id="distinct_values_div" class="CustomTableClass">
    <img src="/_layouts/loading.gif" />
    </div>
    <script language="JavaScript" type="text/JavaScript">
    var siteUrl = '/sitecollection/web'; //use the actual subsite URL here
    var listName = 'mylist'; // use the actual list name here
    var field = "Title" // use the actual field you want to display here
    var divToUpdate = document.getElementById("distinct_values_div");
    var rowClass = "CustomRowClass";
    ExecuteOrDelayUntilScriptLoaded(function(){
    var clientContext = new SP.ClientContext(siteUrl);
    var web = clientContext.get_web();
    var lists = web.get_lists();
    var list = lists.getByTitle(listName);
    var camlQuery = new SP.CamlQuery();
    camlQuery.set_viewXml('<View><Query></Query><RowLimit>500</RowLimit></View>');
    this.collListItem = list.getItems(camlQuery);
    clientContext.load(collListItem,"Include ("+field+")");
    clientContext.executeQueryAsync(
    Function.createDelegate(this, this.onQuerySucceeded),
    Function.createDelegate(this, this.onQueryFailed));
    },"sp.js");
    function onQueryFailed(sender, args){
    divToUpdate.innerHTML = 'Unable to retrieve values: '+args.get_message());
    function onQuerySucceeded(sender, args){
    var allValues = [];
    var listItemEnumerator = collListItem.getEnumerator();
    divToUpdate.innerHTML = "";
    while(listItemEnumerator.moveNext()){
    var listItem = listItemEnumerator.get_current();
    if(!containsString(allValues,listItem.get_item(field)){
    var value = listItem.get_item(field);
    allValues.push(value);
    var newDiv = document.createElement("div");
    newDiv.className = rowClass;
    newDiv.innerHTML = value;
    divToUpdate.appendChild(newDiv);
    function containsString(strArray, text){
    var contains = false;
    for (var i=0; i<strArray.length; i++){
    if(strArray[i]==text){contains = true; break;}
    return contains;
    </script>
    Upload the text file to a library on the site, then add a content editor web part to a page where you want the distinct values to appear. In the content editor web part's properties, edit the Content Link so that it links directly to the text file.  This
    will cause the JavaScript to run on the page.

  • Get distinct values from a coma seperated string variable

    Hi ,
    I am getting an comma seperated string as in parameter, now i want to get the distinct values from that string and will use those values to pass it to a query.
    any help

    try this:
    sorry about the messiness - it's just quickly copied from some badly formatted code....
    TYPE T_FieldArray IS TABLE OF varchar2(255) INDEX BY BINARY_INTEGER;
    function SPLIT_CSV_FIELDS (
    p_Input_Str in varchar2,
    p_Delimiter in varchar2,
    p_Quote_Char in varchar2)
    return t_fieldarray is
    v_FieldArray T_FieldArray;
    v_input_str varchar2(4000);
    v_field_str varchar2(255);
    v_pos number;
    e number := 0;
    v_delim_str varchar2(3);
    cur_pos number;
    begin
    loop
    -- find each delimiter char in string
    v_pos := INSTR(v_input_str, p_Delimiter);
    -- each time delimiter char is found
    if v_pos > 0 then
    -- current field value is current string to position prior to delimiter char
    v_field_str := UPPER(SUBSTR(v_input_str, 1, v_pos - 1));
    -- remove quote char from end of field (if any)
    v_field_str := TRIM(TRANSLATE(v_field_str, NVL(p_Quote_Char, p_Delimiter), ' '));
    -- increment element number
    e := e + 1;
    -- get remainder of input string to check
    v_input_str := SUBSTR(v_input_str, v_pos + 1, LENGTH(v_input_str) - v_pos);
    v_FieldArray(e) := v_field_str;
    else
    -- increment element number
    e := e + 1;
    -- last field value is what's left of input string less quote char (if any)
    v_field_str := TRIM(TRANSLATE(UPPER(v_input_str), NVL(p_Quote_Char, p_Delimiter), ' '));
    v_FieldArray(e) := v_field_str;
    exit;
    end if;
    end loop;
    return v_FieldArray;
    end;

  • "How to get distinct values of sharepoint column using SSRS"

    Hi,
        I have integrated sharepoint list data to SQL Server reporting services. I am using the below to query sharepoint list data using sql reporting services.
    <Query>
       <SoapAction>http://schemas.microsoft.com/sharepoint/soap/GetListItems</SoapAction>
       <Method Namespace="http://schemas.microsoft.com/sharepoint/soap/" Name="GetListItems">
          <Parameters>
             <Parameter Name="listName">
                <DefaultValue>{GUID of list}</DefaultValue>
             </Parameter>
             <Parameter Name="viewName">
                <DefaultValue>{GUID of listview}</DefaultValue>
             </Parameter>
             <Parameter Name="rowLimit">
                <DefaultValue>9999</DefaultValue>
             </Parameter>           
          </Parameters>
       </Method>  
    <ElementPath IgnoreNamespaces="True">*</ElementPath>
    </Query>
    By using this query, I am getting a dataset which includes all the columns of sharepoint list. Among these columns, I wanted to display only 2 columns (i.e Region and Sales type) using chart. I have created a Region parameter but when I click preview, the drop down box is giving me all the repeatative values of region like RG1,RG1,RG1,RG2,RG2,RG2,RG2,RG3.......... I wanted to display only distinct values of Region parameter so that whenever end user select region from the parameter drop down, it will display the respective value of Sales type column.
    Also when I select only RG1 parameter, it is giving me a chart including the sales type of all the Regions. (it should display me only the sales type of RG1) How can I link these 2 columns so that they will display the values respectively.
              I would really appreciate if anyone can help me out with this.
    Thanks,
    Sam.

    Hi Sam,
    By code, the CAML language doesn’t have any reserved word (or tag) to set this particular filter to remove duplicate results.
    In this case, we could use the custom code to get distinct records.
    Here are the detailed steps:
    1.         Create a hidden parameter that gets all the records in one field.
    Note: Please create another dataset that is same of the main dataset. This dataset is used for the parameter.
    2.         Create a function that used to remove the duplicate records.
    Here is the code:
    Public Shared Function RemoveDups(ByVal items As String) As String
    Dim noDups As New System.Collections.ArrayList()
    Dim SpStr
    SpStr = Split(items ,",")
    For i As Integer=0 To Ubound(Spstr)
    If Not noDups.Contains(SpStr(i).Trim()) Then
    noDups.Add(SpStr(i).Trim())
    End If
    Next
    Dim uniqueItems As String() = New String(noDups.Count-1){}
    noDups.CopyTo(uniqueItems)
    Return String.Join(",", uniqueItems)
    End Function
    3.         Create another parameter that will be used for filtering the maindata.
    Please set the available value to be =Split(Code.RemoveDups(JOIN(Parameters!ISSUE_STATUS_TEMP.Value, ",")), ",")
    And the default value to be the value you what such as the first value:
    =Split(Code.RemoveDups(JOIN(Parameters!ISSUE_STATUS_TEMP.Value, ",")), ",").(0)
    4.         Go to the main dataset. Open the property window of this dataset.
    5.         In the “Filters” tab, set the filter to be:
    Expression: <The field to be filter>
    Operator: =
    Value: =Parameters!Region.Value
    The parameter “Region” should be the parameter we created in the step3.
    Now, we should get distinct values of SharePoint columns.
    If there is anything unclear, please feel free to ask.
    Thanks,
    Jin
    Jin Chen - MSFT

  • Get distinct values from plsql array

    Hi,
    I have declared a variable as below in plsql proc.
    type t_itemid is table of varchar2(10);
    inserted set of items in to this using a program
    now i want distinct values from that array how can i get it.

    I am using 9i so i cannot use set operator and more over my problem is that i am declaring the variable inside the plsql block . when i tried i am getting the below errors:
    SQL> r
    1 declare
    2 type t_type is table of varchar2(10);
    3 v_type t_type;
    4 begin
    5 v_type := t_type('toys','story','good','good','toys','story','dupe','dupe');
    6 for i in (select column_value from table(v_type)) loop
    7 dbms_output.put_line(i.column_value);
    8 end loop;
    9* end;
    for i in (select column_value from table(v_type)) loop
    ERROR at line 6:
    ORA-06550: line 6, column 41:
    PLS-00642: local collection types not allowed in SQL statements
    ORA-06550: line 6, column 35:
    PL/SQL: ORA-22905: cannot access rows from a non-nested table item
    ORA-06550: line 6, column 10:
    PL/SQL: SQL Statement ignored
    ORA-06550: line 7, column 22:
    PLS-00364: loop index variable 'I' use is invalid
    ORA-06550: line 7, column 1:
    PL/SQL: Statement ignored

  • CE function to get distinct values from Column table

    Hi All,
    Could you please let me know the appropriate CE function to get the distinct values from column table.
    IT_WORK = SELECT DISTINCT AUFNR FROM :IT_WO_DETAILS;
    Thank you.

    Hi,
    If you have 10g, you can use Model( with model performance is better than connect by )
    Solution
    ========================================================================
    WITH t AS
    (SELECT '0989.726332, 1234.567432, 3453.736379, 3453.736379, 0989.726332, 3453.736379, 1234.567432, 1234.567432, 0989.726332'
    txt
    FROM DUAL)
    SELECT DISTINCT TRIM(CHAINE)
    FROM T
    MODEL
    RETURN UPDATED ROWS
    DIMENSION BY (0 POSITION)
    MEASURES (CAST( ' ' AS VARCHAR2(50)) AS CHAINE ,txt ,LENGTH(REGEXP_REPLACE(txt,'[^,]+',''))+1 NB_MOT)
    RULES
    (CHAINE[FOR POSITION FROM  1 TO NVL(NB_MOT[0],1) INCREMENT 1] =
    CASE WHEN NB_MOT[0] IS NULL THEN TXT[0] ELSE REGEXP_SUBSTR(txt[0],'[^,]+',1,CV(POSITION)) END );
    =========================================================================
    Demo
    =======================================================================
    SQL> WITH t AS
    2 (SELECT '0989.726332, 1234.567432, 3453.736379, 3453.736379, 0989.726332, 3453.736379, 123
    4.567432, 1234.567432, 0989.726332'
    3 txt
    4 FROM DUAL)
    5 SELECT DISTINCT TRIM(CHAINE)
    6 FROM T
    7 MODEL
    8 RETURN UPDATED ROWS
    9 DIMENSION BY (0 POSITION)
    10 MEASURES (CAST( ' ' AS VARCHAR2(50)) AS CHAINE ,txt ,LENGTH(REGEXP_REPLACE(txt,'[^,]+',''))+1 NB_MOT)
    11 RULES
    12 (CHAINE[FOR POSITION FROM  1 TO NVL(NB_MOT[0],1) INCREMENT 1] =
    13 CASE WHEN NB_MOT[0] IS NULL THEN TXT[0] ELSE REGEXP_SUBSTR(txt[0],'[^,]+',1,CV(POSITION)) END );
    TRIM(CHAINE)
    3453.736379
    1234.567432
    0989.726332
    SQL>
    ========================================================================

  • How to get Distinct Values from Answers

    Hi,
    How to get Distinct values from answers, i've tried to put some functions on it.
    Thanks,
    Malli

    Malli,
    Are you trying to fetch data from Dimension Attr OR Fact Measures? Did you try the advance tab - > Advanced SQL Clauses - > Check this box to issue an explicit Select Distinct.

  • Distinct values from dynamic internal tabls

    Hi All,
    I have a dynamic internal tables like <dy_table> , i want to get distinct  values from this internal tables,
    how to do that, structure of dynamic internal tables is dynamic acc. to user conditions.
    regards,
    Anuj

    Hi Anuj
    Just try this,
    CALL METHOD cl_alv_table_create=>create_dynamic_table
    EXPORTING
    it_fieldcatalog = tb_fields_for_it
    IMPORTING
    ep_table = gp_dyn_table.
    ASSIGN gp_dyn_table->* TO <gt_table>.
    ASSIGN LOCAL COPY OF INITIAL LINE OF <gt_table> TO <fs_table>.
    LOOP AT tb_output.
    *To assign value for serial number.
    ASSIGN COMPONENT 1 OF STRUCTURE <fs_table> TO <ls_field>.
    <ls_field> = tb_output-sno.
    UNASSIGN <ls_field>.
    *To assign value for Sales Organization.
    ASSIGN COMPONENT 2 OF STRUCTURE <fs_table> TO <ls_field>.
    <ls_field> = tb_output-vkorg.
    UNASSIGN <ls_field>.
    *To assign Rate for its respective Condition type.
    LOOP AT tb_konp WHERE knumh = tb_output-knumh.
    READ TABLE tb_fieldcat1 WITH KEY fieldname = tb_output-kschl.
    IF sy-subrc EQ 0.
    lv_count = tb_fieldcat1-col_pos.
    ASSIGN COMPONENT lv_count OF STRUCTURE <fs_table> TO <ls_field>.
    IF tb_konp-konwa EQ '%'.
    tb_konp-kbetr = tb_konp-kbetr / co_10.
    <ls_field> = tb_konp-kbetr.
    ELSE.
    <ls_field> = tb_konp-kbetr.
    ENDIF.
    ENDIF.
    ENDLOOP.
    lv_count = lv_count + 1.
    APPEND <fs_table> TO <gt_table>.
    CLEAR <fs_table>.
    ENDLOOP.
    Hope this proves helpful to you.

  • How to create a table with distinct values ?

    I want to create a new table based on an existing table distinct values only, how can I avoid to create the duplicate values ?
    e.g.
    table1
    field1 field2
    0001 ABD
    0001 ABD
    0002 DCF
    0002 DCF
    new table
    field1 field2
    0001 ABD
    0002 DCF
    thanks

    create table table2
    as
    select distinct field1,field2
    from table1

  • Need of SQL query in selecting distinct values from two tables

    hi,
    I need a query for selecting distinct values from two tables with one condition.
    for eg:
    there are two tables a & b.
    in table a there are values like age,sex,name,empno and in table b valuses are such as age,salary,DOJ,empno.
    here what i need is with the help of empno as unique field,i need to select distinct values from two tables (ie) except age.
    can anybody please help me.
    Thanks in advance,
    Ratheesh

    Not sure what you mean either, but perhaps this will start a dialog:
    SELECT DISTINCT a.empno,
                    a.name,
                    a.sex,
                    b.salary,
                    b.doj
    FROM    a,
            b
    WHERE   a.empno = b.empno;Greg

  • What is '#Distinct values' in Index on dimension table

    Gurus!
    I have loaded my BW Quality system (master data and transaction data) with almost equivalent volume as in Production.
    I am comparing the sizes of dimension and fact tables of one of the cubes in Quality and PROD.
    I am taking one of the dimension tables into consideration here.
    Quality:
    /BIC/DCUBENAME2 Volume of records: 4,286,259
    Index /BIC/ECUBENAME~050 on the E fact table /BIC/ECUBENAME for this dimension key KEY_CUBENAME2 shows #Distinct values as  4,286,259
    Prod:
    /BIC/DCUBENAME2 Volume of records: 5,817,463
    Index /BIC/ECUBENAME~050 on the E fact table /BIC/ECUBENAME for this dimension key KEY_CUBENAME2 shows #Distinct values as 937,844
    I would want to know why the distinct value is different from the dimension table count in PROD
    I am getting this information from the SQL execution plan, if I click on the /BIC/ECUBENAME table in the code. This screen gives me all details about the fact table volumes, indexes etc..
    The index and statistics on the cube is up to date.
    Quality:
    E fact table:
    Table   /BIC/ECUBENAME                    
    Last statistics date                  03.11.2008
    Analyze Method               9,767,732 Rows
    Number of rows                         9,767,732
    Number of blocks allocated         136,596
    Number of empty blocks              0
    Average space                            0
    Chain count                                0
    Average row length                      95
    Partitioned                                  YES
    NONUNIQUE  Index   /BIC/ECUBENAME~P:
    Column Name                     #Distinct                                       
    KEY_CUBENAMEP                                  1
    KEY_CUBENAMET                                  7
    KEY_CUBENAMEU                                  1
    KEY_CUBENAME1                            148,647
    KEY_CUBENAME2                          4,286,259
    KEY_CUBENAME3                                  6
    KEY_CUBENAME4                                322
    KEY_CUBENAME5                          1,891,706
    KEY_CUBENAME6                            254,668
    KEY_CUBENAME7                                  5
    KEY_CUBENAME8                              9,430
    KEY_CUBENAME9                                122
    KEY_CUBENAMEA                                 10
    KEY_CUBENAMEB                                  6
    KEY_CUBENAMEC                              1,224
    KEY_CUBENAMED                                328
    Prod:
    Table   /BIC/ECUBENAME
    Last statistics date                  13.11.2008
    Analyze Method                      1,379,086 Rows
    Number of rows                       13,790,860
    Number of blocks allocated       187,880
    Number of empty blocks            0
    Average space                          0
    Chain count                              0
    Average row length                    92
    Partitioned                               YES
    NONUNIQUE Index /BIC/ECUBENAME~P:
    Column Name                     #Distinct                                                      
    KEY_CUBENAMEP                                  1
    KEY_CUBENAMET                                 10
    KEY_CUBENAMEU                                  1
    KEY_CUBENAME1                            123,319
    KEY_CUBENAME2                            937,844
    KEY_CUBENAME3                                  6
    KEY_CUBENAME4                                363
    KEY_CUBENAME5                            691,303
    KEY_CUBENAME6                            226,470
    KEY_CUBENAME7                                  5
    KEY_CUBENAME8                              8,835
    KEY_CUBENAME9                                124
    KEY_CUBENAMEA                                 14
    KEY_CUBENAMEB                                  6
    KEY_CUBENAMEC                                295
    KEY_CUBENAMED                                381

    Arun,
    The cube in QA and PROD are compressed. Index building and statistics are also up to date.
    But I am not sure what other jobs are run by BASIS as far as this cube in production is concerned.
    Is there any other Tcode/ Func Mod etc which can give information about the #distinct values of this Index or dimension table?
    One basic question, As the DIM key is the primary key in the dimension table, there cant be duplicates.
    So, how would the index on Ftable on this dimension table show #distinct values less than the entries in that dimension table?
    Should the entries in dimension table not exactly match with the #Distinct entries shown in
    Index /BIC/ECUBENAME~P on this DIM KEY?

  • XSL - distinct-values

    Hi Vlad,
    I am encountering a problem with the xsl transform, if a value in the input xml is same in same/multiple orders, the unique values gets appended in the same node, in the below example, I have an order with SKU "2" with Qty "1" and SKU "4" with Qty "2", so, my csv file will come with 3 lines, 1 line for SKU "2" and 2 lines for SKU4. The output seems to append both the distinct values (like <ns0:quantity_ordered>*1 2*</ns0:quantity_ordered>) in the same node as shown in the example below. I don't know whether I am using a wrong key in the Item_Data or something else,
    I believe, I am not using the right condition to check for the distinct SKU or using a wron for-each condition, I am not sure if that is the problem. I would appreciate if you could point me to the problem.
    Thanks,
    Venkatesh

    Hi Vlad,
    That was really helpful. Thank You!
    I think this one is almost done except for one particular scenario, where, an order has a duplicate of same SKU (different qty), only one SKU is displayed under Item_data node.
    For example,
    Order 1001 has SKU 1 with Qty of 1 and a duplicate of the same SKU with Qty as 2, In this case, only the first SKU is used and the second one with the Qty 2 gets ignored.
    Order# SKU QTY
    1001 1 1
    1001 1 2
    The input xml would be
    <DailySummary>
         <OrderDetails>
                 <PurchaseOrderNumber>1001</PurchaseOrderNumber>
                 <SKU>1</SKU>
                 <Qty>1</Qty>
         <OrderDetails>
         <OrderDetails>
                 <PurchaseOrderNumber>1001</PurchaseOrderNumber>
                 <SKU>1</SKU>
                 <Qty>2</Qty>
         <OrderDetails>
    <DailySummary>The expected output is,
    <ns2:item_Data>
                <ns0:vendor_item_number>1</ns0:vendor_item_number> (SKU)
                <ns0:quantity_ordered>1</ns0:quantity_ordered> (QTY)
                <ns0:quantity_shipped>1</ns0:quantity_shipped>
                <ns0:unit_cost>1</ns0:unit_cost>
                <ns0:extended_cost>1</ns0:extended_cost>
             </ns2:item_Data>
             <ns2:item_Data>
                <ns0:vendor_item_number>1</ns0:vendor_item_number> (SKU)
                <ns0:quantity_ordered>2</ns0:quantity_ordered> (QTY)
                <ns0:quantity_shipped>2</ns0:quantity_shipped>
                <ns0:unit_cost>1</ns0:unit_cost>
                <ns0:extended_cost>2</ns0:extended_cost>
             </ns2:item_Data>
          </ns1:order>The XSL used to transform is shown below, There is a for each distinct-values for the SKU, can the 'for each' be combined to check for SKU and Qty?, so that for an order if SKU is distinct and Qty is not then take both SKU's and appropriate qty.
                <xsl:for-each select="fn:distinct-values(/tns:DailySummary/tns:OrderDetails[tns:PurchaseOrderNumber = $tmpOrdNo]/tns:SKU/text())">
                  <xsl:variable name="tmpSKU" select="."/>
                  <ns2:item_Data>
                    <ns0:vendor_item_number>
                      <xsl:value-of select="/tns:DailySummary/tns:OrderDetails[tns:PurchaseOrderNumber = $tmpOrdNo and tns:SKU = $tmpSKU][1]/tns:SKU"/>
                    </ns0:vendor_item_number>
                    <ns0:quantity_ordered>
                      <xsl:value-of select="/tns:DailySummary/tns:OrderDetails[tns:PurchaseOrderNumber = $tmpOrdNo and tns:SKU = $tmpSKU][1]/tns:QtyOrdered"/>
                    </ns0:quantity_ordered>
                    <ns0:quantity_shipped>
                      <xsl:value-of select="/tns:DailySummary/tns:OrderDetails[tns:PurchaseOrderNumber = $tmpOrdNo and tns:SKU = $tmpSKU][1]/tns:QtyShipped"/>
                    </ns0:quantity_shipped>
                    <ns0:unit_cost>
                      <xsl:value-of select="/tns:DailySummary/tns:OrderDetails[tns:PurchaseOrderNumber = $tmpOrdNo and tns:SKU = $tmpSKU][1]/tns:Price"/>
                    </ns0:unit_cost>
                    <ns0:extended_cost>
                      <xsl:value-of select="/tns:DailySummary/tns:OrderDetails[tns:PurchaseOrderNumber = $tmpOrdNo and tns:SKU = $tmpSKU][1]/tns:Net"/>
                    </ns0:extended_cost>
                  </ns2:item_Data>
               </xsl:for-each>
               I appreciate all your help,
    Thanks,
    Venkatesh

Maybe you are looking for

  • Export in FCP 7

    In FCP 7, when I try to export a project that plays fine in the timeline and has no offline indications in the browser, get an error message that files are offline.  Running reconnect media has no effect.  Project continues to play but not export and

  • Acrobat X save metadata to XMP file problem

    I am having no luck saving metadata from a PDF to an XMP file using Acrobat X. This has worked properly for me in previous versions of Acrobat, but since upgrading to Acrobat X 10.1.7 the XMP file is given no name automatically, and when saved is zer

  • FCP to FCE(express)

    I have a movie done in FCP sitting on an IMAC computer. I am making a new movie using FC Express on a laptop. I want to take some of my clips from the FCP computer and incorporate them into the FCE new movie. I get error messages that seem to indicat

  • Urgent!!Variable for days not displaying properly!!!

    Hi When executing the Query,Variable for displaying Aging in days are not displaying between the selection.Pls any one help with regard to it.Pls tell wht r the main thing to be taken to consideration for this issue. Thanks

  • Lenovo tablet A3000 doesn't charge as it powered on

    Hello Please I have the following strange problem with my A3000 tablet, recently as I try to cahrge the tablet while it is powered on I got the charge mark on the battery for few seconds and then it disappear and the tablet of course doesn't charge.