Where clause causes empty values

Hi All,
question:
I have a query where I use a filter for DateTime. If I use it only for one day the query works. But if I change it and expand the period for 2 days, the query just returns a zero velue.
Could you please explain me how could that be possible?
Query:
  with
  member [Dimension].[Id].[987] as
    aggregate({
            [Dimension].[Id].&[1234],
            [Dimension].[Id].&[5678],
            [Dimension].[Id].&[9123])
  member [Measures].[MeasureCalculated] as
    ([Measures].[MeasureOriginal], [IsAccepted].[Id].&[1])
select
  non empty ({[Dimension].[Id].[987]}) on columns,
  ({[Measures].[MeasureCalculated]}) on rows
from
  [Cube]
where({[Date].[DateUtc].[Day].&[2014]&[1]&[2] : [Date].[DateUtc].[Day].&[2014]&[1]&[3]})
Thanks in advance!

Hi Istvan_Szabo,
I have tested it on my local environment, the same syntax queery work fine on AdventureWorks cube, which you can see on the screenshot below.
So in your scenario, the issue can be related to the metedata on your cube, please run the query below and check if the result is correct or not.
SELECT [Measures].[MeasureCalculated] ON 0,
[Date].[DateUtc].[Day].MEMBERS ON 1
FROM
(SELECT ({[Date].[DateUtc].[Day].&[2014]&[1]&[2] : [Date].[DateUtc].[Day].&[2014]&[2]&[28]}) ON 0
FROM [CUBE]
Regards,
Charlie Liao
TechNet Community Support

Similar Messages

  • How to set the where clause of a value set on the basis of a form field

    I am using a DFF(Descriptive FlexField), which needs to display the value of a certain column(say columnA) on the basis of the value of another column(say columnB).
    So i have created a value set which points to the table which has both these columns, and the DFF uses this value set. However, the problem is that I have not put any where clause in the value set, because of which i cannot handle the exact fetch returns more than one rows error.
    The query has to be as follows:
    select ColumnA from tbl where ColumnB = [ a form value ];
    What I want to know is how can i get the value of a certain field of a certain block of the form in the above query.
    Edited by: 981615 on Jan 14, 2013 12:48 AM
    Edited by: 981615 on Jan 14, 2013 12:48 AM

    Just have a look over these two statements if it solves your problem
    one time where clause
    Set_Block_Property('BLOCK_NAME',ONETIME_WHERE,your form item);
    dynamic where clause
    set_block_property('BLOCK_NAME'default_where, your form itme)
    you can where clause at run time from any procedure or some triggers

  • Dynamic where clause for MULTIPLE values

    In the following of dynamic where clause?
    i have some somewhat different problem.
    Is a dynamic where clause for multiple values possible?
    If the inputvariable varCode1,varCode2,varCode3,varCode4 are 0 then show all id's otherwise filter the resultset on var1 and/or var2,and/or var3,and/or var4.
    Example table:
    create table t
    (d int,var int);
    insert into t values (1 ,1 );
    insert into t values (2 ,1 );
    insert into t values (3 ,2 );
    insert into t values (4 ,3 );
    insert into t values (5 ,4 );
    insert into t values (6 ,4 );
    insert into t values (7 ,4 );
    insert into t values (8 ,4 );
    insert into t values (9 ,5 );
    insert into t values (10, 6);
    insert into t values (11, 6);
    So what i want to change the where clause upon the value of the varCodes. If var1 and var are not 0 a "AND" should be used otherwise an "OR"
    select id
    from tst
    where var = DECODE( :varCode1, 0, var, :varCode1)
    or/and(?) DECODE( :varCode2, 0, var, :varCode2)
    or DECODE( :varCode3, 0, var, :varCode3)
    or DECODE( :varCode4, 0, var, :varCode4)

    Please turn off your Caps Lock
    and try this link
    Dynamic WHERE clause

  • Where clause as expression value for parameter?

    Is it possible to put a where clause in a expression so I could use as a parameter? I have 3 documents I was going to make as available values, but not sure how to put all of this in the expression. 
    Where clause:
    where document = 'doc1'
    and sentdate = (Select max(sentdate) from Communication where document = 'doc1')

    Hi Lezgettdrunk,
    According to your description, you want to specify available values for a report parameter.
    In Reporting Services, if we want to specify the available values for a report parameter in Report Parameter Properties, we should get those values from specified values or a dataset. When we select the “Specify values” option, we can give each label corresponding
    value. When we select the “Get values from a query” option, we should select a dataset which contains documents values. In your scenario, you could create a dataset with where clause to get document values, then specify parameter available values use this
    dataset.
    Reference:
    Lesson 2: Adding Parameters to Create a List of Available Values (SSRS)
    If you have any question, please feel free to ask.
    Best regards,
    Qiuyun Yu
    Qiuyun Yu
    TechNet Community Support
    Thank you! This worked for me.

  • Where clause with null values

    I need to have a where clause but either/both of the two attributes compared could be null. How can I make this work, atm it just returns no records even though rows do exist.
    Thanks

    Andrew,
    I think you didn't read correctly what I wrote. I said:
    "Even if a column is unique you still can have several nulls in it"
    So I didnt speak about the case where you have severeal columns in a unique constraint but only ONE.
    SQL> CREATE TABLE tab1 (col1 number);
    Table created.
    SQL> ALTER table tab1 add constraint tab1_col1_uk unique (col1);
    Table altered.
    SQL> INSERT INTO tab1 VALUES (1);
    1 row created.
    SQL> INSERT INTO tab1 VALUES (2);
    1 row created.
    SQL> INSERT INTO tab1 VALUES (2);
    INSERT INTO tab1
    ERROR at line 1:
    ORA-00001: unique constraint (MUELLERMAU.TAB1_COL1_UK) violated
    SQL> INSERT INTO tab1 VALUES (NULL);
    1 row created.
    SQL> INSERT INTO tab1 VALUES (NULL);
    1 row created.
    And even if you have a unique constraint over several columns you can still have more than on records containing only nulls in all fields related to that unique contraint.
    SQL> CREATE TABLE nn (col1 number, col2 varchar2(3));
    Table created.
    SQL> ALTER TABLE nn ADD CONSTRAINT nn_uk UNIQUE (col1, col2);
    Table altered.
    SQL> INSERT INTO nn VALUES (NULL,NULL);
    1 row created.
    SQL> INSERT INTO nn VALUES (NULL,NULL);
    1 row created.
    Regards
    Maurice

  • HELP: WHERE Clause based on value of the column

    I am selecting from a table as follows and want to have a where condition that is dependent of the value of the column, type of the current row.
    CREATE TABLE tbl (INT id, VARCHAR type, VARCHAR comment)
    I have 3 different values for the type column, EMPLOYEE, CUSTOMER, SUPPLIER. What I want is to have a where clause in my select that is based on the value of type.
    I tried the following but was not successful..
    SELECT * from tbl
    CASE
    WHEN type = 'EMPLOYEE' THEN
    WHERE comment LIKE '%employee%'
    WHEN type = 'CUSTOMER' THEN
    WHERE comment LIKE '%customer%'
    WHEN type = 'SUPPLIER' THEN
    WHERE comment LIKE '%supplier%'
    END
    I am not proficient with stored procedures so if you could please tell me how to do it with straight query, I would greatly appreciated it..
    Thank you,

    Or maybe this:
    SELECT *
      FROM tbl
    WHERE "COMMENT" LIKE
              CASE TYPE
                 WHEN 'EMPLOYEE'
                    THEN '%employee%'
                 WHEN 'CUSTOMER'
                    THEN '%customer%'
                 WHEN 'SUPPLIER'
                    THEN '%supplier%'
              END

  • Runtime Where Clause cause on Language other than en-us ORA-01422

    Hi All,
    I have a very strange situation.
    It seems the "Runtime Where Clause" does n't get pick up when I toggle to different language other than en-us
    If I set my language on the brower to user en-us, it works, fine, select 1 record.
    If I change to Spanish or other Language, I got ORA-01422, It didn't seem "Runtime Where Clause" working at all.
    Please help.
    Or How shall I find out if the "Runtime Where Clause" got apply at all ?
    Best
    --John                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    ok Scott,
    Now I really need your advise.
    My main reason to use Runtime Where Clause is because I have more than 2 columns to compose the primary key. Since APEX has problem to apply "Runtime Where Clause" on different language.
    Here is what I did to get around.
    In Source: Automatic Row Processing (DML)
    I specify like this
    "F|#OWNER#:CMNTS:P71_HCC_APRVD_ID,:P71_VER_NO.:P71_CMNT_ID:HCC_APRVD_ID,VER_NO,CMNT_ID"
    Then it works, but of cause, due to the APEX limitation, when I go back to PAGE definition, it changes back to just one column, so the key is DON"T SAVE it.,re-publish the language
    I don't know id there any other side effect
    --John

  • Where clause causing a query to slow down in a cursor

    I have a table "the_table" with about 10,000 rows and four columns (id, description, inventory, and category).
    This query returns all rows immediately:
        select id
             , description
             , inventory
        from the_table
        where category =  nvl(null, category);
    However, when it is put into a cursor, like this:
    (p_user_category is a user-defined variable which can be null if the user wants all of the rows)
        c_results  sys_refcursor;
        open c_results for
            select id
                 , description
                 , inventory
            from the_table
            where category =  nvl(p_user_category, category);
        fetch c_results into v_id, v_description, v_inventory;
        close c_results;
    then it takes five minutes to return even just one row when p_user_category is null.
    However, if I change the where clause to:
        where (p_user_category is null or category = p_user_category)
    then it returns all rows immediately.
    It started being a problem right around the time of the most recent update - I am running 11.2.0.2.0 (64-bit production).

    The optimizer is smart enough to recognise that null is null, so "nvl(null,category)" collapses to "category", and your predicate "category = nvl(null, category)" is transformed to "category is not null" (if it's allowed to be null) or simply disappears - so the SQL test is not the same as the PL/SQL run.
    In PL/SQL your manual rewrite is not logicall the same as the original unless you have declared category to be non-null because your first disjunct will allow rows with a null category to be reported, while the original query would lose them.
    Check the execution plans for the SQL and the PL/SQL versions.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    Now on Twitter: @jloracle

  • Filter Records in WHERE clause iReports using values passed from a prgram

    I have searched for iReports manual and what i can see are docs on sale. I have managed to create jrxml file, execute it in jsp and actually view the report.
    Now i have a big list of customers from various branches and have various categories. I would like to know how to pass the parameters so that i retrieve a small list of items. e.g. WHERE cu.branch=200 AND cu.category=10. That is i would like to pass 20 and 10 to the jrxml query stored.
    In iReports i saw parameters, variables and fields but it seems like these are displayable fields.
    How will i achieve this. Am seeking for assistance.
    null

    >
    Please help me to use an associate array in SQL query (WHERE clause).
    select *
    bulk collect into some_array
    >
    there is no variable 'some_array' in what you posted.
    If you want help with your code you have to post the code you are really using, not some hacked-up version of it that has errors.
    Here is sample code that shows how to treat a collection as a table using the TABLE operator
    -- type to match emp record
    create or replace type emp_scalar_type as object
      (EMPNO NUMBER(4) ,
       ENAME VARCHAR2(10),
       JOB VARCHAR2(9),
       MGR NUMBER(4),
       HIREDATE DATE,
       SAL NUMBER(7, 2),
       COMM NUMBER(7, 2),
       DEPTNO NUMBER(2)
    -- table of emp records
    create or replace type emp_table_type as table of emp_scalar_type
    declare
    tb emp_table_type;
    deptnoList sys.OdciNumberList;
    BEGIN
    select emp_scalar_type(empno, ename, job, mgr, hiredate, sal, comm, deptno)
    bulk collect into tb from emp;
    SELECT deptno bulk collect
    INTO deptnoList
    FROM dept where deptno not in (select deptno from table(tb));
    for i in 1..deptnoList.count loop
    dbms_output.put_Line(deptnoList(i));
    end loop;
    END;Note that tb is a collection and is useds in the subquery 'select deptno from table(tb)'.

  • Using where clause with hardcode value in execute immediate

    Dear Experts, I am using below in stored procedure getting exception,
    EXECUTE IMMEDIATE 'DELETE FROM CC.TB WHERE COL='HG'';
    where col is varchar2(30) in CC.TB
    Please guide how can i use above statement in stored procedure
    Thanks,

    DBA wrote:
    Dear Experts, I am using below in stored procedure getting exception,
    EXECUTE IMMEDIATE 'DELETE FROM CC.TB WHERE COL='HG'';
    where col is varchar2(30) in CC.TB
    Please guide how can i use above statement in stored procedure
    Thanks,Why are you using Dynamic SQL? DELETE statement is a DML statement and its valid inside a PL/SQL block.
    So you can remove the execute immediate and write your DELETE statement directly.
    begin
      delete from cc.tb where col = 'HG';
    end;

  • LOV with where clause containing a value from a row in an updateable report

    I have an updateable report in which a possible value of one column depends on the value of another. I want to use LOVs (there are two different possible), and per row choose which LOV I use, does anyone know if this is possible?
    Thanks
    Wendy

    Wendy - I see that you were able to use the correlated subquery technique (in your other post). This sounds like a slightly different problem but if your query uses the htmldb_item API, I think you could achieve your aim using this same method and decode.
    Scott

  • Dynamic where clause - hard-parse

    Hi there,
    I landed in the middle of a situation that I'm not seeing any solution possible, so I’m turning to you for help.
    We have a batch script that occurs once a day that handles a lot of information (we're talking about thousands of data).
    In many situations we have to run select's with the where clause dynamically build.
    That is, we have a table with something like: ID - COLUMN_NAME - OPPERATOR - COLUMN_VALUE - DEPENDING_VALUE
    Our database is unique for a large number of clients (we have about 90% of my country City Hall's and then some more...), and DEPENDING_VALUE depends on each client.
    So, for each client, we build the where clause based on that table and then we get the data from another table with something like SELECT ABC FROM XPTO WHERE || WHERE_CLAUSE_BUILD using dynamic sql.
    So far so good, except we can have many different combinations of the where clause causing the select to be hard-parse for each client and we are trying to think of a better way to do this. Unfortunately we haven’t found one yet and I’m not seeing any light in the end of the tunnel…
    This is kind of difficult to explain, so I hope I was clear enough.
    Any help would be greatly appreciated.
    Thank you

    Hi, thank you for your answer.
    We are already using the USING clause and binding.
    The (we think kind of stupid) idea we had was:
    We created an array of 100 positions.
    Then we made a function that get’s the where clause and populates the array making something like:
    ‘where a = :param1 and b = :param2 and c= :param3’ and so on.
    For the remaining positions, we added ‘and 1 = :paramMax+1 and … and 1 = :paramMax+N and …’ and put :paramMax+1.value = 1 and :paramMax+N = 1.
    Then, when using the select with the where clause we opened a cursor using :param1.value, :param2.value, :param3.value, … :param100.value
    But this still is hard-parsing because I can have:
    Select x from y where a = :param1 and b = :param2 and 1 = :param3 …
    And for another client
    Select x from y where a = :param1 and 1 = :param2 and 1 = :param3 …
    The statements are different, that’s why I’m not seeing any solution.
    Thanks

  • Userenv('LANG') in where clause

    Would the use of userenv('LANG') in where clause cause the whole sql to not use indexes? The exact sql is at the end of this and I am seeing full table scan for one of the tables. By the way, this was after running SQL Tuning profile in Grid.
    Regards,
    SELECT items.cross_reference ITEM , to_number(null) ITEM_ID , nvl(items.description, T.description) ITEM_DESCRIPTION , B.inventory_item_id INVENTORY_ITEM_ID , items.cross_reference_type ITEM_IDENTIFIER_TYPE ,NULL item_identifier_type_meaning ,B.concatenated_segments INVENTORY_ITEM , NULL ADDRESS , NULL CUST_ADDRESS , NULL ITEM_DEFINITION_LEVEL FROM mtl_cross_reference_types types , mtl_cross_references items , MTL_SYSTEM_ITEMS_TL T , MTL_SYSTEM_ITEMS_B_KFV B WHERE (types.disable_date is null or types.disable_date>sysdate) and types.cross_reference_type = items.cross_reference_type AND items.inventory_item_id = B.inventory_item_id AND B.organization_id = :15 AND B.INVENTORY_ITEM_ID = T.INVENTORY_ITEM_ID AND B.ORGANIZATION_ID = T.ORGANIZATION_ID AND T.LANGUAGE = userenv('LANG') and B.customer_order_enabled_flag='Y'

    Thanks Yingkuan; I have 10.1.0.5; I did a little test of my own and ran tkprof with explain plan on both the scenarios; they are exactly same. So seems userenv('LANG') vs putting string like 'US' does not make any change.
    Thank you for your quick response.
    Regards,

  • Join and Multiple where clauses: which is better??

    There was an argument between a colleague and I. He prefers building his views joining many tables with many where clause while I am cute with my join which is simpler and more understandable for me. So, it started an argument on which is a superior way of joining tables.
    I will actually like to know we is faster and better: using JOINs or using multiple where clauses to retrieve values from multiple tables.?

    Dave:
    "Are we talking about the difference between Oracle Joins and ANSI Joins?
    e.g.
    Select d.dept_name, e.emp_name
    from dept d, emp e
    where d.dept_id = e.dept_id"
    That is not really an "Oracle Join". That syntax works on just about every SQL database I have ever worked with. The (+) syntax for an outer join is Oracle specific, but some other databases use a similar style for outer joins (something like a.c += b.c or a.c *= b.c).
    OP:
    There are things you can do with the ANSI style syntax that either cannot be done, or cannot be done as easily, with Oracle's syntax. Most notably, outer joining one table to more than one other tables, and FULL OUTER joins.
    Having said that, in my experience, both are rather rare occurrences, so I tend to stick to doing the jopins in the WHERE clause because that is what I am used to.
    John

  • Use of DECODE and NULL value in a WHERE clause

    hi all,
    I came into an issue trying to use the DECODE function in a simple where clause.
    this is my test case
    CREATE TABLE tab_test (lev NUMBER, code VARCHAR2(10), val VARCHAR2(10));
    INSERT INTO tab_test VALUES (1, NULL, 'val11');
    INSERT INTO tab_test VALUES (1, NULL, 'val12');
    INSERT INTO tab_test VALUES (1, '13', 'val13');
    INSERT INTO tab_test VALUES (2, '21', 'val21');
    INSERT INTO tab_test VALUES (1, '22', 'val22');
    INSERT INTO tab_test VALUES (1, '23', 'val23');
    and this is the query
    SELECT * FROM tab_test WHERE code = DECODE(:lev,1,NULL,:cod)
    as you can see running this query, setting :lev to 1 will return an empty record set, instead of the expected first two rows (as it will be, running "select * from tab_test where code is null").
    is there a way to overcome this issue? thanks for help

    hi Frank,
    I can confirm that the queries do work when run on TOAD, but do not when they are put in the WHERE clause of my data block. I guess the problem relies on some data block setting; I should investigate on Forms forum.
    Anyway, here is my test case, including data and some examples. You can realize that it works good
    CREATE TABLE TAB_TEST
    LEV NUMBER,
    CODE VARCHAR2(10 BYTE),
    VAL VARCHAR2(10 BYTE)
    Insert into tab_test
    (LEV, CODE, VAL)
    Values
    (3, 'val21', 'val3_211');
    Insert into tab_test
    (LEV, CODE, VAL)
    Values
    (2, 'val21', 'val3_212');
    Insert into tab_test
    (LEV, VAL)
    Values
    (1, 'val11');
    Insert into tab_test
    (LEV, VAL)
    Values
    (1, 'val12');
    Insert into tab_test
    (LEV, VAL)
    Values
    (1, 'val13');
    Insert into tab_test
    (LEV, CODE, VAL)
    Values
    (2, 'val11', 'val21');
    Insert into tab_test
    (LEV, CODE, VAL)
    Values
    (2, 'val12', 'val22');
    Insert into tab_test
    (LEV, CODE, VAL)
    Values
    (2, 'val13', 'val23');
    COMMIT;
    SELECT * FROM TAB_TEST
    CONNECT
    BY PRIOR val = code
    START WITH (CASE
    WHEN :LIV = 1 AND code IS NULL THEN 'OK'
    WHEN :LIV != 1 AND code = :COD THEN 'OK'
    END = 'OK')
                   AND VAL = :V
    :LIV = 1
    :COD = [any]
    :V = 'val11'
    LEV     CODE     VAL
    1          val11
    2     val11     val21
    3     val21     val3_211
    3     val21     val3_212
    :LIV = 1
    :COD = [any]
    :V = 'val12'
    LEV     CODE     VAL
    1          val12
    2     val12     val22
    :LIV = 2
    :COD = 'val11'
    :V = 'val21'
    LEV     CODE     VAL
    2     val11     val21
    3     val21     val3_211
    2     val21     val3_212

Maybe you are looking for