Distinct distribution query

Hi all,
I have the next records table example:
WITH taba
     AS (SELECT 2000 AS id, 'ORDEM' AS name, 'FILEA' AS description FROM DUAL
         UNION ALL
         SELECT 2000 AS id, 'ORDEM' AS name, 'FILEB' AS description FROM DUAL
         UNION ALL
         SELECT 2000 AS id, 'ORDEM' AS name, 'FILEC' AS description FROM DUAL
         UNION ALL
         SELECT 2001 AS id, 'ORDEM' AS name, 'FILEA' AS description FROM DUAL
         UNION ALL
         SELECT 2001 AS id, 'ORDEM' AS name, 'FILEB' AS description FROM DUAL
         UNION ALL
         SELECT 2001 AS id, 'ORDEM' AS name, 'FILEC' AS description FROM DUAL
         UNION ALL
         SELECT 2002 AS id, 'ORDEM' AS name, 'FILEA' AS description FROM DUAL
         UNION ALL
         SELECT 2002 AS id, 'ORDEM' AS name, 'FILEB' AS description FROM DUAL
         UNION ALL
         SELECT 2002 AS id, 'ORDEM' AS name, 'FILEC' AS description FROM DUAL)
SELECT *
  FROM tabaI need a query that distribute the DESCRIPTION column just once in each ID, like this:
ID     NAME     DESCRIPTION
2000   ORDEM     FILEA
2001   ORDEM     FILEB
2002   ORDEM     FILECIs indifferent if each ID have FILEA, B or C. I just need once DESCRIPTION per ID. This is other possible solution:
ID     NAME     DESCRIPTION
2000   ORDEM     FILEB
2001   ORDEM     FILEA
2002   ORDEM     FILECNotes: My table have more diferent records with diferent ID's, NAMES or DESCRIPTION.
What I need is: for each pair ID, NAME, I have just one DESCRIPTION
I have tried using OVER PARTITION clause but with bad results.
Anyone can help me?
Thanks in advance.
Regards,
Filipe Almeida

It is not clear if all IDs have same set of names/descriptions. For starters:
WITH taba
     AS (SELECT 2000 AS id, 'ORDEM' AS name, 'FILEA' AS description FROM DUAL
         UNION ALL
         SELECT 2000 AS id, 'ORDEM' AS name, 'FILEB' AS description FROM DUAL
         UNION ALL
         SELECT 2000 AS id, 'ORDEM' AS name, 'FILEC' AS description FROM DUAL
         UNION ALL
         SELECT 2001 AS id, 'ORDEM' AS name, 'FILEA' AS description FROM DUAL
         UNION ALL
         SELECT 2001 AS id, 'ORDEM' AS name, 'FILEB' AS description FROM DUAL
         UNION ALL
         SELECT 2001 AS id, 'ORDEM' AS name, 'FILEC' AS description FROM DUAL
         UNION ALL
         SELECT 2002 AS id, 'ORDEM' AS name, 'FILEA' AS description FROM DUAL
         UNION ALL
         SELECT 2002 AS id, 'ORDEM' AS name, 'FILEB' AS description FROM DUAL
         UNION ALL
         SELECT 2002 AS id, 'ORDEM' AS name, 'FILEC' AS description FROM DUAL
SELECT  id,
        name,
        description
   FROM (
         SELECT  t.*,
                 DENSE_RANK() OVER(ORDER BY id) rnk1,
                 DENSE_RANK() OVER(ORDER BY description) rnk2
           FROM  taba t
  WHERE rnk1 = rnk2
        ID NAME  DESCR
      2000 ORDEM FILEA
      2001 ORDEM FILEB
      2002 ORDEM FILEC
SQL> SY.

Similar Messages

  • Toplink issues select distinct type query before fetch

    When we have type classifiers identified by value, Toplink issues a 'SELECT DISTINCT TYPE' on the parent object and then queries the child records for that type, is there way to avoid the select distinct
    type query from Toplink in queries, this is slowing down the query performance. thanks

    More info
    This is the Report Query:
    Session session = PersistenceFactory.newSession();
    ExpressionBuilder eb = new ExpressionBuilder();
    ReportQuery query = new ReportQuery( eb );
    query.setReferenceClass( FXSingleLegDealC.class );
    query.useCollectionClass( ArrayList.class );
    query.setSelectionCriteria( eb.get( "objectID" ).equal( 249994 ) );
    query.addAttribute( "objectID", eb.get( "objectID" ) );
    query.addAttribute( "parentDealFXDealLegCurrency1Amount", eb.get( "dealFXSingleLegParent" ).get( "fxDealLeg" ).get( "currency1Amount" ) );
    query.addAttribute( "parentDealFXDealLegCurrency1Amount", eb.get( "dealFXSingleLegParent" ).get( "fxDealLeg" ).get( "currency2Amount" ) );
    query.addAttribute( "parentDealFXDealLegCurrency1Amount", eb.get( "dealFXSingleLegParent" ).get( "fxDealLeg" ).get( "currency1" ).get( NamedEntity.ShortName) );
    query.addAttribute( "parentDealFXDealLegCurrency1Amount", eb.get( "dealFXSingleLegParent" ).get( "counterpartyA" ).get( NamedEntity.ShortName) );
    ArrayList result = ( ArrayList ) session.executeQuery( query );
    This is the SQL Generated:
    SELECT t0.id, t1.ccy1Amt, t1.ccy2Amt, t2.shortName, t3.shortName FROM IdcCpty t3, IdcInstr t2, IdcDeal t1, IdcDeal t0
    WHERE (((t0.id = ?) AND (t0.type = ?)) AND ((((t1.id = t0.parentId) AND (t1.type = ?)) AND ((t2.id = t1.ccy1Id) AND (t2.type = ?))) AND ((t3.id = t1.cptyAId) AND (t3.type = ?))))
    bind => [249994, IdcFXSLegDealC, IdcFXSLegDealC, IdcCrncC, IdcLglEntC]
    Not sure why we need to query for type on t2 and t3 after we have made a join by id (t2.id = t1.ccy1Id,t3.id = t1.cptyAId), this is really breaking our performance, we do not want to add an index on
    the type column
    can someone please respond!?

  • Using ROWID returns less rows than if use distinct in query

    Hi,
    I am writting  the following query to get distinct purchase order number from a specific received date. this returns me total 620 rows.:
    select  distinct pha.segment1 from apps.po_headers_all pha, apps.RCV_TRANSACTIONS rcv
    where 1=1
    and trunc(rcv.transaction_date) between to_date(:P_FROM_DATE,'YYYY/MM/DD HH24:MI:SS') and to_date(:P_TO_DATE,'YYYY/MM/DD HH24:MI:SS')
    and pha.po_header_id=rcv.po_header_id
    and pha.type_lookup_code='STANDARD'
    and pha.authorization_status ='APPROVED'
    and pha.cancel_flag='N'
    if i write the query using ROWID to get the distinct Purchase order number its giving me 580 rows:
    select  pha.segment1 from apps.po_headers_all pha, apps.RCV_TRANSACTIONS rcv
    where 1=1
    and trunc(rcv.transaction_date) between to_date(:P_FROM_DATE,'YYYY/MM/DD HH24:MI:SS') and to_date(:P_TO_DATE,'YYYY/MM/DD HH24:MI:SS')
    and pha.po_header_id=rcv.po_header_id
    and rcv.rowid=(select max(rowid) from apps.RCV_TRANSACTIONS rcv where rcv.po_header_id=pha.po_header_id)
    and pha.type_lookup_code='STANDARD'
    and pha.authorization_status ='APPROVED'
    and pha.cancel_flag='N';
    Can anyone tell me why? I want to use this ROWID query in a valueset in oracle apps.

    That's probably because some purchase orders have rcv transactions out of the range (p_from_date, p_to_date). You should include the condition on the dates in the (select max(rowid)...) subquery as well. And more generally, the first query seems like a better/simpler choice than the second one.
    Hope it helps.

  • Running Total & Distinct Count Query

    Crystal 10.0.0.533 CR Professional
    Hope you can assist.
    I have a report listing deals signed, each deal has a corresponding category i.e. industry type, Accountant, Chiropractor, Financial Services, etc.
    I am undertaking a Distinct Count on these categories so that in the group footer it is showing number of different categories signed in a period (the report is grouped into different date periods). This is working OK.
    However, I need to EXCLUDE the category from this distinct count if the deal value is zero.
    I have tried using a formula to show a blank field if the value is zero, however it appears to be distinctly counting the blank as a category?
    Any assistance would be much appreciated.
    Tracy

    Deffinetly it will be less than what you expect for grand total. It is because when you are calculating distinct count for each group suppose
    Group A has categories A,B,C,D-->distinct count (4)
    Group B has C,D,E,F-->distinct count (4)
    but while calculating grand total then the distinct count will be
    A,B,C,D,E,F --> grand total (6) but not (8).
    In this case you need to use mannual running total like this
    whileprintingrecords;
    numbervar i;
    i:=i+{running total};
    place this in group footer and create another fomula like this
    whileprintingrecords;
    numbervar i;
    place this in report footer to get the correct grand total.
    Regards,
    Raghavendra

  • SCCM 2012 R2 Distribution Query

    Hello,
             Few weeks back I configured the SCCM server in single machine (SCCM, SQL, DP etc..) and I have created the ADR for Patch deployment.
            Today I have configured some Distribution Point (on Windows 2008 R2 and Windows 7 machines).
    Question:
            How should I point the new DP's (in ADR or deployment package) also to distribute the content, where I have to make the changes. Kindly help.

    Use the Distribute Content Wizard to distribute the content of the Deployment Package to the new DPs. The next time the ADR will run it will update the package on all the associated DPs.
    My Blog: http://www.petervanderwoude.nl/
    Follow me on twitter: pvanderwoude

  • Can't get query to work.  table alias in subquery in FROM clause

    How can I rearrange this query to work?
    SELECT
                               TO_CHAR(dt.date_time, 'YYYY-MM-DD') start_date,
                                       (SELECT COUNT(*) FROM
                                            (SELECT DISTINCT a.non_asp, a.start_time, a.end_time
                                                  FROM appointments a
                      WHERE  a.start_time >= dt.date_time AND a.start_time < dt.date_time + 1
                                       ) num_overlap
                             FROM
                                  table(times_pkg.between_times(TO_DATE('2010-05-30'),
                                             TO_DATE('2010-07-03'), 60*24, 'Y')) dtbetween_times is a table function that returns times at given intervals.
    I am trying to get a count of distinct (non_asp, start_time, end_time) sets that fall on each day.
    However, it doesn't recognize dt.date_time in the FROM clause.

    Hi,
    A sub-query can be correlated only to its immediate parent. You're trying the correlate the SELECT DISTINCT sub-query to its grandparent.
    You can re-write the sub-query as a join, like this:
    SELECT  TO_CHAR(dt.date_time, 'YYYY-MM-DD') start_date,
         a.num_overlap
    FROM     table ( times_pkg.between_times ( TO_DATE('2010-05-30'),
                               TO_DATE('2010-07-03'),
                               60*24,
                               'Y'
               ) dt
    JOIN    (
           SELECT    start_time,
                    end_time,
                  COUNT (DISTINCT non_asp)     AS num_overlap
           FROM         appointments
         )  a         ON  a.start_time         >= dt.date_time
                  AND a.start_time         < dt.date_time + 1
    ;You could also eliminate the extra level between the SELECT DISTINCT sub-query and the main query by using SELECT (DISTINCT ...).

  • Oracle Spatial Query

    I have created two tables the first called pai_equal created from the query below
    create table pai_equal as
    (select /*+ ORDERED */ l.*, t.toid
    from sub_lt l, sub_topoarea t
    where mdsys.sdo_relate(t.geoloc, l.geoloc,
    'mask=EQUAL querytype=WINDOW')='TRUE');
    This returns 4 rows which is correct
    This query selects the terrier polygons that are made up of one topo_area polygon only (and no more and align exactly)
    The second table is called inside_coveredby created as follows
    create table inside_coveredby as
    select /*+ ORDERED */ l.*, t.toid
    from sub_lt l, sub_topoarea t
    where mdsys.sdo_relate(t.geoloc, l.geoloc,
    'mask=INSIDE+COVEREDBY querytype=WINDOW')='TRUE'
    order by l.mi_prinx;
    Returns 1142 undistinct rows, 475(distinct)
    This query selects terrier polygons that are
    (a) made up or two or more topo area polygons and where the boundaries align exactly
    (b) made up of one or more topo area polygons and where the boundaries do not align exactly
    What I want to do next is select all the terriers that are not included in either of the above 2 queries. Totals should now add up to 754 (4 +475+ ?)as the original terrier table contains 754 features
    I think I need to select from sub_lt where mi_prinx is not in inside+coveredby or the equal table?
    Has anyone any ideas on how to write this?
    Your help as usual is much appreciated

    You can use SQL difference operator to do this:
    select toid from sub_lt
    MINUS
    select /*+ ORDERED */ l.*, t.toid
    from sub_lt l, sub_topoarea t
    where mdsys.sdo_relate(t.geoloc, l.geoloc,
    'mask=INSIDE+COVEREDBY querytype=WINDOW')='TRUE'
    order by l.mi_prinx;
    This should give you everything other than inside+coveredby.
    If you want to include the equal also,
    change the mask to inside+coveredby+equal.

  • DB Adapter Query - Polling using nested select

    When polling a table to initiate a BPEL process, can I use a nested select in the expression.

    The visual expression builder does not currently support this so you need to specify the raw sql directly.
    If you use the DeletePollingStrategy there is a way you can specify the exact sql string for both the 'select' and the after read 'delete'. So if you write the where clause yourself it can contain nested selects.
    This is the readme from the new PureSQLSelect database adapter sample. Also you may want to look at the PureSQLPolling sample.
    This sample shows you how you can bypass the designer's visual where clause builder to specify arbitrarily complex sql strings for your selects.
    Like the other samples, this sample uses the basic Movies schema.
    The Steps:
    Create a basic select. Made sure it has the same name and number of input parameters as you will need for your sql string. In this case create a single input parameter and call it 'genre_param'.
    Create a trivial where clause in the wizard expression builder using genre_param. I.e. genre.like(genre_param)
    Ideally run the sample once just to make sure everything else works and to get a template SQL. The select ... FROM ... part will be the same.
    Open the toplink_mappings.xml file. Look for an element called <database-query>. There will likely only be one. A sample is presented here:
    <query-manager>
    <descriptor-query-manager>
    <existence-check>Check cache</existence-check>
    <descriptor-named-queries>
    <database-query>
    <query-name>selectByGenreSelect</query-name>
    <query-should-maintain-cache>true</query-should-maintain-cache>
    <cascade-policy>1</cascade-policy>
    <should-bind-all-parameters>undefined</should-bind-all-parameters>
    <should-cache-statement>undefined</should-cache-statement>
    <should-use-wrapper-policy>true</should-use-wrapper-policy>
    <query-timeout>0</query-timeout>
    <query-arguments>
    <string>genre_param</string>
    </query-arguments>
    <query-argument-types>
    <values>java.lang.String</values>
    </query-argument-types>
    <reference-class>PureSQLSelect.Movies</reference-class>
    <refresh-identity-map>false</refresh-identity-map>
    <cache-usage>2</cache-usage>
    <lock-mode>0</lock-mode>
    <distinct-state>0</distinct-state>
    <query-indirection>
    <in-memory-query-indirection>
    <policy>0</policy>
    </in-memory-query-indirection>
    </query-indirection>
    <main-expression>
    <expression>
    <operator-type>AND</operator-type>
    <expression-list>
    <expression>
    <operator-type>Like</operator-type>
    <first-argument>
    <argument>
    <query-key-name>genre</query-key-name>
    <outer-join>false</outer-join>
    <to-many>false</to-many>
    <argument-class>oracle.toplink.tools.workbench.expressions.QueryableArgumentRepresentation</argument-class>
    </argument>
    </first-argument>
    <second-argument>
    <argument>
    <parameter-name>genre_param</parameter-name>
    <argument-class>oracle.toplink.tools.workbench.expressions.ParameterArgumentRepresentation</argument-class>
    </argument>
    </second-argument>
    <expression-class>oracle.toplink.tools.workbench.expressions.BinaryExpressionRepresentation</expression-class>
    </expression>
    </expression-list>
    <expression-class>oracle.toplink.tools.workbench.expressions.CompoundExpressionRepresentation</expression-class>
    </expression>
    </main-expression>
    <type>oracle.toplink.queryframework.ReadAllQuery</type>
    </database-query>
    </descriptor-named-queries>
    </descriptor-query-manager>
    </query-manager>
    We want to switch this query from using a high-level expression to a pure sql string. You will remove the <main-expression> element and replace it with a <sql-string> element of your own devising.
    Your replacement should look something like this:
    <query-manager>
    <descriptor-query-manager>
    <existence-check>Check cache</existence-check>
    <descriptor-named-queries>
    <database-query>
    <query-name>selectByGenreSelect</query-name>
    <query-should-maintain-cache>true</query-should-maintain-cache>
    <cascade-policy>1</cascade-policy>
    <should-bind-all-parameters>undefined</should-bind-all-parameters>
    <should-cache-statement>undefined</should-cache-statement>
    <should-use-wrapper-policy>true</should-use-wrapper-policy>
    <query-timeout>0</query-timeout>
    <sql-string>SELECT DELETED, DIRECTOR, GENRE, LAST_UPDATED, RATED, RATING, RELEASE_DATE, RUN_TIME, SEQUENCENO, STARRING, STATUS, SYNOPSIS, TITLE, TOTAL_GROSS, VIEWER_RATING FROM MOVIES WHERE (upper(GENRE) LIKE upper(concat(concat('%', #genre_param), '%'))) ORDER BY TOTAL_GROSS desc</sql-string>
    <query-arguments>
    <string>genre_param</string>
    </query-arguments>
    <query-argument-types>
    <values>java.lang.String</values>
    </query-argument-types>
    <reference-class>PureSQLSelect.Movies</reference-class>
    <refresh-identity-map>false</refresh-identity-map>
    <cache-usage>2</cache-usage>
    <lock-mode>0</lock-mode>
    <distinct-state>0</distinct-state>
    <query-indirection>
    <in-memory-query-indirection>
    <policy>0</policy>
    </in-memory-query-indirection>
    </query-indirection>
    <type>oracle.toplink.queryframework.ReadAllQuery</type>
    </database-query>
    </descriptor-named-queries>
    </descriptor-query-manager>
    </query-manager>
    Gotchas:
    The tempation to start writing pure sql may be terrible to some, but it was intentionally left out of the wizard for good reasons. Please be wary of the following when specifying pure sql:
    -There is a way to set the pure sql string in the Mapping Workbench, but when you edit the partnerlink to refresh the toplink_mappings.xml you may get an exception due to the query being in a pure sql format. For this reason you need to manually edit the toplink_mappings.xml, and again every time your run the wizard and hit finish after that.
    -The #genre_param is a TopLink convention for writing a sql string which still takes parameters. At runtime if you enter 'Action' in the bpel console, you will see this sql:
    SELECT DELETED, DIRECTOR, GENRE, LAST_UPDATED, RATED, RATING, RELEASE_DATE, RUN_TIME, SEQUENCENO, STARRING, STATUS, SYNOPSIS, TITLE, TOTAL_GROSS, VIEWER_RATING FROM SYSTEM.MOVIES WHERE (GENRE LIKE ?)
    bind => [Action]
    The #genre_param gets replaced with the value of the input parameter genre_param.
    -When specifying pure sql you should be aware of the following:
    -maintenance issues
    -loss of database platform independence
    -The sql needs to conform with the way TopLink works. It is recommended that you do not change the SELECT ... FROM ... part of the query. TopLink's design is to read from one table at a time. If an Employee has an Address, then the Address is read with a hidden relationship query. There are two advanced TopLink features which optimize reading from multiple tables, called joinedAttribute and batchAttribute reading, but the combination of these features with raw sql was not explored here. So to avoid danger you can only really affect the top level query, and only rewrite the where clause.
    -The pure sql route does not interact with most TopLink features, especially batch reading (on by default), and can not be combined with the following:
    -LogicalDeletePollingStrategy
    -SequencingPollingStrategy (LastUpdated, LastReadId, File)
    These features extend the selection criteria at runtime.

  • Query and other association

    Good Afternoon Expert;
    I dont know why I cant figure out the logic to this and I have spent 4hours thinking about this. All help will be appreciated. I have a distribution query that produces the following output
    Placename   distribution Amount
    Berlin            5
    London         4
    Paris             6Now the idea, is basically, I have another table called table_A that contains the following information
    Id                  Placename                     Away
    G34563          Berlin                             N
    G33445          London                          N
    G34455          Paris                               Y
    G55567          Berlin                              Y
    G55561          Berlin                              N
    G55562          London                          Y
    G55563          Paris                              Y
    G55564          Paris                     Y
    G55565          London                         Y
    .Now the idea, is basically using the distribution query result, i am meant to go into table_A and pickout various ID, and have those ID evenly distributed to each placename. So far example
    let say we have a place name called berlin and the distribution Amount is 5, then I am meant to go into the table_A and pick out several Id that possess at least 2 placename that is Berlin, 2 placename that is Paris, 1 Placename that is London for a total of 5.
    So the final result and display should be something like this
    ID                     Placename           Away
    G34563             Berlin                   N
    G55567             Berlin                   N
    G55563             Paris                    Y
    G55564             Paris                   Y
    G33445          London                   NHow can this be achieved. All helps and idea will be appreciated.

    Good Afternoon Expert;
    I dont know why I cant figure out the logic to this and I have spent 4hours thinking about this. All help will be appreciated. I have a distribution query that produces the following output
    Placename   distribution Amount
    Berlin            5
    London         4
    Paris             6Now the idea, is basically, I have another table called table_A that contains the following information
    Id                  Placename                     Away
    G34563          Berlin                             N
    G33445          London                          N
    G34455          Paris                               Y
    G55567          Berlin                              Y
    G55561          Berlin                              N
    G55562          London                          Y
    G55563          Paris                              Y
    G55564          Paris                     Y
    G55565          London                         Y
    .Now the idea, is basically using the distribution query result, i am meant to go into table_A and pickout various ID, and have those ID evenly distributed to each placename. So far example
    let say we have a place name called berlin and the distribution Amount is 5, then I am meant to go into the table_A and pick out several Id that possess at least 2 placename that is Berlin, 2 placename that is Paris, 1 Placename that is London for a total of 5.
    So the final result and display should be something like this
    ID                     Placename           Away
    G34563             Berlin                   N
    G55567             Berlin                   N
    G55563             Paris                    Y
    G55564             Paris                   Y
    G33445          London                   NHow can this be achieved. All helps and idea will be appreciated.

  • Distinct on 10 million records

    Hello everyone.
    I have a table called BL_DOCUMENTS which has 10 million records in it.
    It has 'DocumentId' column which is the PrimaryKey.
    I created an index on three columns:
    CREATE INDEX IX_BD_CREA_DOCU_ISDE_ISCUR ON BL_DOCUMENTS (CREATORID ASC, ISDELETED ASC, ISCURRENT ASC)
    I run a simple query to get the 'CreatorId' column's values with 'distinct' (there are currently 25,000 different ids):
    select O., rownum rnum from(*
    SELECT distinct  D.CreatorId  ObjectId FROM BL_DOCUMENTS  D
    WHERE D.IsCurrent = 1 AND  D.IsDeleted = 0
    *     ORDER BY ObjectId DESC*
    *) O where rownum <= 1000*
    This query runs for 7-10 seconds.
    If I remove the distinct the query runs for 0.007 secs.
    How can I improve this?

    DevMTs wrote:
    I try that but it's not improved.Still changing index column order should give some improvement since INDEX SKIP SCAN DESCENDING is a bit more costly operation than INDEX RANGE SCAN DESCENDING:
    SQL> create table BL_DOCUMENTS(CreatorId number,IsCurrent number,IsDeleted number);
    Table created.
    SQL> CREATE INDEX IX_BD_CREA_DOCU_ISDE_ISCUR ON BL_DOCUMENTS (CREATORID ASC, ISDELETED ASC, ISCURRENT ASC);
    Index created.
    SQL> exec dbms_stats.gather_table_stats(ownname => user, tabname => 'BL_DOCUMENTS',cascade => true);
    PL/SQL procedure successfully completed.
    SQL> explain plan for
      2  select O.*, rownum rnum from(
      3  SELECT distinct D.CreatorId ObjectId FROM BL_DOCUMENTS D
      4  WHERE D.IsCurrent = 1 AND D.IsDeleted = 0
      5  ORDER BY ObjectId DESC
      6  ) O where rownum <= 1000
      7  /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 4024680831
    | Id  | Operation                     | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT              |                            |     1 |    13 |     1 (100)| 00:00:01 |
    |*  1 |  COUNT STOPKEY                |                            |       |       |            |          |
    |   2 |   VIEW                        |                            |     1 |    13 |     1 (100)| 00:00:01 |
    |   3 |    SORT UNIQUE NOSORT         |                            |     1 |    39 |     1 (100)| 00:00:01 |
    |*  4 |     INDEX SKIP SCAN DESCENDING| IX_BD_CREA_DOCU_ISDE_ISCUR |     1 |    39 |     0   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       1 - filter(ROWNUM<=1000)
       4 - access("D"."ISDELETED"=0 AND "D"."ISCURRENT"=1)
           filter("D"."ISCURRENT"=1 AND "D"."ISDELETED"=0)
    18 rows selected.
    SQL> drop index IX_BD_CREA_DOCU_ISDE_ISCUR;
    Index dropped.
    SQL> CREATE INDEX IX_BD_CREA_DOCU_ISDE_ISCUR ON BL_DOCUMENTS (ISCURRENT,ISDELETED,CREATORID);
    Index created.
    SQL> exec dbms_stats.gather_table_stats(ownname => user, tabname => 'BL_DOCUMENTS',cascade => true);
    PL/SQL procedure successfully completed.
    SQL> explain plan for
      2  select O.*, rownum rnum from(
      3  SELECT distinct D.CreatorId ObjectId FROM BL_DOCUMENTS D
      4  WHERE D.IsCurrent = 1 AND D.IsDeleted = 0
      5  ORDER BY ObjectId DESC
      6  ) O where rownum <= 1000
      7  /
    Explained.
    SQL> @?\rdbms\admin\utlxpls
    PLAN_TABLE_OUTPUT
    Plan hash value: 3922126944
    | Id  | Operation                      | Name                       | Rows  | Bytes | Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT               |                            |     1 |    13 |     1 (100)| 00:00:01 |
    |*  1 |  COUNT STOPKEY                 |                            |       |       |            |          |
    |   2 |   VIEW                         |                            |     1 |    13 |     1 (100)| 00:00:01 |
    |   3 |    SORT UNIQUE NOSORT          |                            |     1 |    39 |     1 (100)| 00:00:01 |
    |*  4 |     INDEX RANGE SCAN DESCENDING| IX_BD_CREA_DOCU_ISDE_ISCUR |     1 |    39 |     0   (0)| 00:00:01 |
    PLAN_TABLE_OUTPUT
    Predicate Information (identified by operation id):
       1 - filter(ROWNUM<=1000)
       4 - access("D"."ISCURRENT"=1 AND "D"."ISDELETED"=0)
    17 rows selected.
    SQL> In any case, post execution plan.
    SY.

  • Duplicate rows in Multiselect

    Hi All,
    Our system have been recently upgraded to OBI 10.1.3.3.
    We are facing a problem with the multiselect prompts in the application. Now some of the columns used as sources of the multiselect Dashboard prompts have duplicate rows.
    Any idea how to suppress the duplicates and display only the distinct records?
    Thanks in advance

    If the values that you are using in your dashboard prompt are from tables that are considered 'Dimension' tables in the Business Layer, then you will be OK.
    From what I understand, the Oracle BI server always does a select distinct when querying dimension only data. It's only when you combine data from Business Model fact tables, that it removes the DISTINCT from the SQL that is generated.
    Hope this helps.

  • Should whitespace be preserved by default?

    Hi:
    I'm using xmltype.transform() to apply a stylesheet to an XML document and it seems to be ignoring whatever attempts I make to have spaces in certain places. Is the default to strip spaces out? I've even tried adding preserve-whitespace in the stylesheet though I think it may be deprecated. This didn't fix things either.
    Here's the procedure that loads the data and applies the transform.
    PROCEDURE GetSQLQueryFromXML(XMLClob in CLOB, XSLStylesheet in CLOB,
                SQLQuery out CLOB) IS
        -- Define the local variables
      xmldata               sys.XMLType ;  -- The XMLType format of the XML to transform
      xsldata               sys.XMLType ;  -- The XMLType format of the stylesheet to apply
      sqlQuery_XMLType      sys.XMLType ;  -- The XMLType format of the SQL query.
      --v_SQLQuery            Clob;     -- Holds XML Clob
    BEGIN
      -- Get the XML document using the getXML() function defined in the database.
      -- Since XMLType.transform() method takes XML data as XMLType instance,
      -- use the XMLType.createXML method to convert the XML content received
      -- as CLOB into an XMLType instance.
      xmldata := XMLType.createXML(XMLClob);
      -- Since XMLType.transform() method takes an XSL stylesheet as XMLType instance,
      -- use the XMLType.createXML method to convert the XSL content received as CLOB
      -- into an XMLType instance.
      xsldata := XMLType.createXML(XSLStylesheet);
      -- Use the XMLtype.transform() function to get the transformed XML instance.
      -- This function applies the stylesheet to the XML document and returns a transformed
      -- XML instance.
      -- DBMS_XMLGEN.CONVERT() is being used as a work around to an Oracle bug that
      -- prevented us from being able to surround text strings with apostrophes for
      -- searches.  dbms_xlmgen.convert returns a Clob which is what we want anyway.
      -- The bug is supposedly fixed in Oracle 11g.
      if(xmldata is null) then
        dbms_output.put_line('*** xmldata is null!!!');
      end if;
      if(xsldata is null) then
        dbms_output.put_line('*** xsldata is null!!!');
      end if;
      SQLQuery := dbms_xmlgen.convert(xmldata.transform(xsldata).getStringVal(),
                    dbms_xmlgen.ENTITY_DECODE);
    END GetSQLQueryFromXML;What I'm trying to do is transform some XML into a SQL query string. I'm losing whitespace though so in certain cases (using LIKE or NOT LIKE) it generates improper SQL. This isn't an Oracle XML thing because I get the same error when working in a "playground" site. ( http://www.paulchaplin.com/lab/xslt/ pretty handy!)
    My test XML file is:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <variable type="QueryContent">
      <queryType><![CDATA[PERSON]]></queryType>
      <tableName><![CDATA[PERSON]]></tableName>
      <queryItem>
      <item>
        <distinct><![CDATA[false]]></distinct>
        <columnName><![CDATA[PERSON_KEY]]></columnName>
        <fieldName><![CDATA[PERSON_KEY]]></fieldName>
        <criteria><![CDATA[=]]></criteria>
        <fieldType><![CDATA[INTEGER]]></fieldType>
        <value><![CDATA[8901234]]></value>
      </item>
      <item>
        <distinct><![CDATA[true]]></distinct>
        <columnName><![CDATA[LAST_NAME]]></columnName>
        <fieldName><![CDATA[LAST_NAME]]></fieldName>
        <criteria><![CDATA[=]]></criteria>
        <fieldType><![CDATA[STRING]]></fieldType>
        <value><![CDATA[SMITH]]></value>
      </item>
      <item>
        <distinct><![CDATA[false]]></distinct>
        <columnName><![CDATA[FIRST_NAME]]></columnName>
        <fieldName><![CDATA[FIRST_NAME]]></fieldName>
        <criteria><![CDATA[=]]></criteria>
        <fieldType><![CDATA[STRING]]></fieldType>
        <value><![CDATA[JANE]]></value>
      </item>
      <item>
        <distinct><![CDATA[false]]></distinct>
        <columnName><![CDATA[MIDDLE_NAME]]></columnName>
        <fieldName><![CDATA[MIDDLE_NAME]]></fieldName>
        <criteria><![CDATA[=]]></criteria>
        <fieldType><![CDATA[STRING]]></fieldType>
        <value><![CDATA[MIDNAME]]></value>
      </item>
      <item>
        <distinct><![CDATA[false]]></distinct>
        <columnName><![CDATA[SUFFIX_NAME]]></columnName>
        <fieldName><![CDATA[SUFFIX_NAME]]></fieldName>
        <criteria><![CDATA[=]]></criteria>
        <fieldType><![CDATA[STRING]]></fieldType>
        <value><![CDATA[MS]]></value>
      </item>
      <item>
        <distinct><![CDATA[false]]></distinct>
        <columnName><![CDATA[FULL_NAME]]></columnName>
        <fieldName><![CDATA[FULL_NAME]]></fieldName>
        <criteria><![CDATA[=]]></criteria>
        <fieldType><![CDATA[STRING]]></fieldType>
        <value><![CDATA[SMITH, JANE]]></value>
      </item>
      <item>
        <distinct><![CDATA[false]]></distinct>
        <columnName><![CDATA[EMPLOYER_ORG_CODE]]></columnName>
        <fieldName><![CDATA[EMPLOYER_ORG_CODE]]></fieldName>
        <criteria></criteria>
        <fieldType><![CDATA[STRING]]></fieldType>
        <value />
      </item>
      <item>
        <distinct><![CDATA[true]]></distinct>
        <columnName><![CDATA[SSN]]></columnName>
        <fieldName><![CDATA[SSN]]></fieldName>
        <criteria><![CDATA[=]]></criteria>
        <fieldType><![CDATA[STRING]]></fieldType>
        <value><![CDATA[222222222]]></value>
      </item>
      <item>
        <distinct><![CDATA[false]]></distinct>
        <columnName><![CDATA[GRADE_CODE]]></columnName>
        <fieldName><![CDATA[GRADE_CODE]]></fieldName>
        <criteria></criteria>
        <fieldType><![CDATA[PICKLIST]]></fieldType>
        <value/>
      </item>
      <item>
        <distinct><![CDATA[false]]></distinct>
        <columnName><![CDATA[POB_CITY]]></columnName>
        <fieldName><![CDATA[POB_CITY]]></fieldName>
        <criteria><![CDATA[=]]></criteria>
        <fieldType><![CDATA[STRING]]></fieldType>
        <value><![CDATA[PASCAGOULA]]></value>
      </item>
      <item>
        <distinct><![CDATA[false]]></distinct>
        <columnName><![CDATA[POB_COUNTY]]></columnName>
        <fieldName><![CDATA[POB_COUNTY]]></fieldName>
        <criteria><![CDATA[=]]></criteria>
        <fieldType><![CDATA[STRING]]></fieldType>
        <value><![CDATA[JACKSON]]></value>
      </item> 
      <item>
        <distinct><![CDATA[false]]></distinct>
        <columnName><![CDATA[POB_STATE_CODE]]></columnName>
        <fieldName><![CDATA[POB_STATE_CODE]]></fieldName>
        <criteria><![CDATA[=]]></criteria>
        <fieldType><![CDATA[PICKLIST]]></fieldType>
        <value><![CDATA[MS]]></value>
      </item>
      <item>
        <distinct><![CDATA[false]]></distinct>
        <columnName><![CDATA[POB_COUNTRY_CODE]]></columnName>
        <fieldName><![CDATA[POB_COUNTRY_CODE]]></fieldName>
        <criteria><![CDATA[=]]></criteria>
        <fieldType><![CDATA[STRING]]></fieldType>
        <value><![CDATA[USA]]></value>
      </item>
      <item>
        <distinct><![CDATA[false]]></distinct>
        <columnName><![CDATA[BIRTH_DATE]]></columnName>
        <fieldName><![CDATA[BIRTH_DATE]]></fieldName>
        <criteria><![CDATA[=]]></criteria>
        <fieldType><![CDATA[DATE]]></fieldType>
        <fieldFormat>DD-MON-YYYY</fieldFormat>
        <value><![CDATA[11-NOV-1911]]></value>
      </item>
      <item>
        <distinct><![CDATA[false]]></distinct>
        <columnName><![CDATA[SX]]></columnName>
        <fieldName><![CDATA[SX]]></fieldName>
        <criteria><![CDATA[=]]></criteria>
        <fieldType><![CDATA[STRING]]></fieldType>
        <value><![CDATA[F]]></value>
      </item>
      <item>
        <distinct><![CDATA[true]]></distinct>
        <columnName><![CDATA[SITE_CODE]]></columnName>
        <fieldName><![CDATA[SITE_CODE]]></fieldName>
        <criteria><![CDATA[NOT LIKE]]></criteria>
        <fieldType><![CDATA[STRING]]></fieldType>
        <value><![CDATA]></value>
    </item>
    <item>
    <distinct><![CDATA[false]]></distinct>
    <columnName><![CDATA[JOB_TITLE]]></columnName>
    <fieldName><![CDATA[JOB_TITLE]]></fieldName>
    <criteria><![CDATA[LIKE]]></criteria>
    <fieldType><![CDATA[STRING]]></fieldType>
    <value><![CDATA[CLERK]]></value>
    </item>
    </queryItem>
    </variable>
    My XSL file is:<?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="text" omit-xml-declaration="yes" indent="no"/>
    <!-- IF there are any column flagged as distinct, we'll be doing selecting -->
    <!-- just those columns with DISTINCT from the general query. -->
    <!-- Generate the DISTINCT outer query first, if there is one. Then generate -->
    <!-- the query that will always be generated. Then close the outer query if -->
    <!-- there is one. -->
    <xsl:preserve-space elements="*" />
    <xsl:variable name="aspace"> </xsl:variable>
    <xsl:template match="/">
    <xsl:apply-templates select="." mode="distincts"/>
    <xsl:apply-templates select="." mode="normal"/>
    <xsl:apply-templates select="." mode="closeDistincts"/>
    </xsl:template>
    <!-- If there are any column flagged with DISTINCT we'll create an outer query -->
    <xsl:template match="/" mode="distincts">
    <xsl:for-each select="/variable/queryItem/item/distinct[text() = 'true']">
    <xsl:variable name="distinctCount" select="position()" />
    <xsl:if test="$distinctCount = 1">
    <xsl:text>SELECT DISTINCT </xsl:text>
    </xsl:if>
    <xsl:if test="$distinctCount &gt; 1">
    <xsl:text>, </xsl:text>
    </xsl:if>
    <xsl:value-of select="../columnName"/>
    </xsl:for-each>
    <!-- If we had any DISTINCT elements, generate the "FROM (" clause. -->
    <xsl:if test="count(/variable/queryItem/item/distinct[text() = 'true']) > 0">
    <xsl:text> FROM (</xsl:text>
    </xsl:if>
    </xsl:template>
    <!-- If we did a DISTINCT outer query then we need to close it with a ')' -->
    <xsl:template match="/" mode="closeDistincts">
    <xsl:for-each select="/variable/queryItem/item/distinct[text() = 'true']">
    <xsl:variable name="distinctCount" select="position()" />
    <xsl:if test="$distinctCount &lt; 2">
    <xsl:text>) </xsl:text>
    </xsl:if>
    </xsl:for-each>
    </xsl:template>
    <!-- This will generate a query. It may or not be an inner query. -->
    <xsl:template match="/" mode="normal">
    <xsl:variable name="apos">'</xsl:variable>
    select * from
    <xsl:value-of select="/variable/tableName"/>
    where 1=1
    <xsl:for-each select="variable/queryItem/item">
    <xsl:choose>
    <!-- if the value node is not null... -->
    <!-- <xsl:when test="./value/text()[normalize-space(.)]"> -->
    <xsl:when test="./value/text()">
    AND
    <xsl:value-of select="./fieldName"/>
    <xsl:copy-of select="$aspace"/><xsl:value-of select="./criteria"/><xsl:copy-of select="$aspace"/>
    <xsl:choose>
    <xsl:when test="string(./fieldType)='NUMBER'">
    <xsl:value-of select="./value"/>
    </xsl:when>
    <xsl:when test="string(./fieldType)='INTEGER'">
    <xsl:value-of select="./value"/>
    </xsl:when>
    <xsl:otherwise>
    <!-- Type is something that we treat as a string compare. -->
    <!-- Currently those types are String, CLOB, RADIO and PICKLIST -->
    <xsl:copy-of select="$apos"/>
    <xsl:value-of select="./value"/>
    <xsl:copy-of select="$apos"/>
    </xsl:otherwise>
    </xsl:choose>
    </xsl:when>
    </xsl:choose>
    </xsl:for-each>
    </xsl:template>
    </xsl:stylesheet>
    Not how the last two predicates need spaces around the operators.  It doesn't matter when the operator is "=" or ">" but "LIKE" and "NOT LIKE" mess things up when trying to run the generated SQL.SELECT DISTINCT LAST_NAME, SSN, SITE_CODE FROM (
    select * from
    PERSON
    where 1=1
    AND
    PERSON_KEY=8901234
    AND
    LAST_NAME='SMITH'
    AND
    FIRST_NAME='JANE'
    AND
    MIDDLE_NAME='MIDNAME'
    AND
    SUFFIX_NAME='MS'
    AND
    FULL_NAME='SMITH, JANE'
    AND
    SSN='222222222'
    AND
    POB_CITY='PASCAGOULA'
    AND
    POB_COUNTY='JACKSON'
    AND
    POB_STATE_CODE='MS'
    AND
    POB_COUNTRY_CODE='USA'
    AND
    BIRTH_DATE='11-NOV-1911'
    AND
    SX='F'
    AND
    SITE_CODENOT LIKE'B'
    AND
    JOB_TITLELIKE'CLERK')
    Thanks.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          

    This thread may help : Oracle XSLT Transformation not preserving space in text element [Oracle XSLT Transformation not preserving space in text element: A Workaround]

  • LOV's auto refresh and having unique values.

    Hi, I'm having LOVs connected with few attributes of a table, and those fields are used in view criteria of the table.
    This view criteria is used in the af:query component as search fields.
    To avoid the duplicates in the LOV, i created a separate view for each of the attribute, using the distinct key , and connected them with the attribute via view accessors. So that the af:query component , search field drop downs can give unique value of the column.
    There is an another requirement, to refresh the LOVs of the search field, when there is a change in the database. To accomplish this auto refresh property of the view's query, i added the PK of the table with each view. By doing this i can see the latest values of the database in the UI . ie, the LOVs of af:query getting the changes of database.
    But this one causing, the duplicate values to be in LOV, and the distinct key word in the view's query will not work because of the PK of table is added to query.
    I tried different ways to query , like groupby . But no success.
    I need both auto refresh as well as unique values in the LOVs of the af:query . Could some one point me a reference to solve this. Thanks .
    Edited by: user642477 on Oct 7, 2010 10:52 AM

    user642477 wrote:
    Hi, I'm having LOVs connected with few attributes of a table, and those fields are used in view criteria of the table.
    This view criteria is used in the af:query component as search fields.
    To avoid the duplicates in the LOV, i created a separate view for each of the attribute, using the distinct key , and connected them with the attribute via view accessors. So that the af:query component , search field drop downs can give unique value of the column.
    why you have done that what is your reason?!!! it seems so wierd to me? you could easily add distinct on query of the viewobject!

  • Using Dimension Measures - COUNT, etc.. within Fact Results

    All,
    I am running into an issue that I imagine is relatively straight forward if you know what youre doing but I cant seem to get it right. I am trying to include some counts from my Dimensions alongside measures from my fact table.
    To do this I have setup my Dimensions as Facts that I require counts from. In a simple example I have:
    EVENT_FACT
    Timestamp
    User Id
    Building Id
    Event Type
    existing measure = Event Count
    USER_BUILDING_DIM
    User Id
    Building Id
    Building Type
    USER_BUILDER_DIM contains a record for each user and the building they are contained in along with a type. Users can exist in multiple buildings so this table's key is User Id and Building Id.
    When I run a query from the FACT table I want to show the total number of Distinct Users in that build next to each result. To make this work I have done the following:
    1. Setup the USER_BUILDING_DIM as a fact in my BMM, the only table that joins to this Fact table is the USER_BUILDING_DIM itself
    2. In the USER_BUILDING_DIM (DIMENSION) hierarchy I have 3 levels, total, building and user ... I want my count of all users for each building
    3. Created a measure called User Count - Distinct in the USER_BUILDING_DIM (FACT) table and set it to the Building level in the USER_BUILDING_DIM (DIMENSION) hierarchy. That is the only level I set for this measure
    When I go into answers and I create a query like:
    Building Id, Event Count, User Count - Distinct
    The query comes back perfect and shows me for each building the total event count from the EVENT_FACT table and then alongside it the Distinct User count for users in that building counted from the USER_BUILDING_DIM table.
    The Issue occurs when I add any other dimensions into the request that hang off of the EVENT_FACT table, such as Month from my Time Dimension which also hangs off of the EVENT_FACT table:
    Month, Event Count, User Count - Distinct
    Now, for the query above the User Count - Distinct value returns nothing and when I look in the logs Answers is not even performing a count anymore and instead is just joining the USER_BUILDING_DIM to the EVENT_FACT table and TIME Dimension
    Any thoughts .. thanks in advance
    K

    Hi,
    You are getting no results in "User Count Distinct" when you also drag "Month" because "USER_BUILDING_DIM_FACT" doesn't join to the Time Dimension.
    This Fact doesn't have any Time information so it's not possible to obtain the "USER_BUILDING_DIM_FACT"."User Count Distinct" measure with Time Dimension columns.
    You are trying to count users by Month but you don't have this information in your model. You can only count users by month which have events associated to it.
    Regards

  • Linq Error : Invalid 'where' condition. An entity member is invoking an invalid property or method

    Hi,
    I am running Linq query in CRM2013 and throwing error : Invalid 'where' condition. An entity member is invoking an invalid property or method.
    My Code is as below;
    var conntionRecord1Id = (from connectionBase in orgServiceContext.CreateQuery("connection")
    where connectionBase["record1roleid"] != null
    select connectionBase["record1id"]).Distinct();
    var query = from opportunity in orgServiceContext.CreateQuery("opportunity")
    where !conntionRecord1Id.Contains(opportunity["opportunityid"])
    orderby opportunity["createdon"] ascending
    select new
    Topic = opportunity.Attributes.Contains("name") == true ? opportunity["name"] : null,
    OpportunityId = opportunity.Attributes.Contains("opportunityid") == true ? opportunity["opportunityid"] : null,
    PostalCode = opportunity.Attributes.Contains("new_address_postalcode") == true ? opportunity["new_address_postalcode"] : null,
    Error throwing on second query.
    Please help
    Thanks,

    Not sure I can help with that.  I might debug this code and see what data resides in the first query for conntionRecord1Id.
    Are you trying to get a list of opportunityId's?  If so you might need to do a foreach loop on the results of conntionRecord1Id.
     Something like...
    foreach(var recordid in conntionRecord1Id)
              (do something to the record...)

Maybe you are looking for

  • Is it possible to get a refund if i bought an album with extremely bad sound quality?

    As asked in the title, is it possible to get a refund if i bought an album with extremely bad sound quality? I am very unsatisfied with my latest purchase of the album "Never take ffriendship personal" by "Anberlin" ... I can find all the songs in mu

  • Downgrading from Tiger 10.4.11 to Panther 10.3.5?

    So my old IMAC G5 (17in 512MB ram running Panther 10.3.9) recently had service at the apple store to replace the motherboard and the power supply. As a courtesy, they installed Tiger 10.4.11 when my computer shipped with disks for Panther 10.3.5. Whi

  • I cannot find a link to Itunes 10.7 64-bit version. Can someone help please?

    I am looking for the 64-bit version on ITunes 10.7.   The download pages mentions the 64-bit installer but it's nowhere to be found. Can someone assist please?

  • ALV: Create a new view in Settings

    I get an exception "Dynamic type conflict when assigning references " when trying to create new view in Settings of ALV. The ABAP call stack was: Method: MAP_FROM_MODEL_CELL_EDITOR of program CL_SALV_WD_PERSISTENCE========CP Method: MAP_FROM_MODEL_CO

  • Do not import duplicates-BUT DOES

    I had exported all of my images that had Keywords added to them to 'start over' my library. I imported those back to establish my base library. All is good. I then went back to my non-keyword tagged images, many of which are those that were imported