Filter using Function resulting incorrect where cause

Hi,
I have a requirement wherein i have to filter a column based on a combination of mutiple hierarchy dimensions for which i am using Filter Using Function
ex.
Filter Metric A Using Dimesion A - Range 50 -100
Filter Metric A Using Dimension A - Range 25 - 50, Dimension B Range 0 -100
When i have a report with these metrics alone then it works fine but when both metrics are exposed on a single report
The where clause results in something like this
(Dimension A > 50 OR Dimnesion B > 0) AND (Dimension A > 25 OR Dimension A < 100 OR Dimesnion B < 100) AND Dimesnion A < 50
To sum it up its random and incorrect, any ideas as to why this could happen ??
Any pointers etc would be highly appreciated.

Hi,
I have a requirement wherein i have to filter a column based on a combination of mutiple hierarchy dimensions for which i am using Filter Using Function
ex.
Filter Metric A Using Dimesion A - Range 50 -100
Filter Metric A Using Dimension A - Range 25 - 50, Dimension B Range 0 -100
When i have a report with these metrics alone then it works fine but when both metrics are exposed on a single report
The where clause results in something like this
(Dimension A > 50 OR Dimnesion B > 0) AND (Dimension A > 25 OR Dimension A < 100 OR Dimesnion B < 100) AND Dimesnion A < 50
To sum it up its random and incorrect, any ideas as to why this could happen ??
Any pointers etc would be highly appreciated.

Similar Messages

  • Problem using function call in WHERE part of a Report's SQL query

    I tried doing some searches on this, but couldn't find anything. I'm trying to run something similar to the following query in my report, but keep getting a "Query cannot be parsed within the Builder" error:
    SELECT function1(TABLE2.ID) A
    FROM TABLE1, TABLE2
    WHERE TABLE1.ID = TABLE2.ID AND
               TABLE1.NAME = 'BLAH' AND
               TABLE2.DATE > SYSTIMESTAMP AND
               (function2(TABLE2.ID) = 'YES' OR
                function3(:USER_ID) = 'YES')
    ORDER BY TABLE1.NAMEWhy won't this work? I can take out the 2 lines with function calls from the WHERE clause, and it works, so I'm assuming that APEX doesn't like something about my function calls. I know the functions are valid and work properly, because I tested them independently. Can anyone see what the problem is? Thanks!

    Here's the actual query:
    SELECT BUILD_EXT_RES_LIST(EXT_FILE.ID) A
    FROM EXT_FILE_RES, EXT_FILE
    WHERE EXT_FILE_RES.ON_OWNER_PROFILE = 'Y' AND
          EXT_FILE.OWNER_ID = :PROFILE AND
          EXT_FILE.ID = EXT_FILE_RES.EXT_ID AND
         (RES_SUBSCRIBER_YN(EXT_FILE.ID,:CURR_ID) = 'YES' OR
          ADMINYESNO(:CURR_ID,:PROFILE) = 'YES')
    ORDER BY EXT_FILE.FILE_NAMEAnd here's the actual error message:
    1 error has occurred
    Query cannot be parsed within the Builder. If you believe your query is syntactically correct, check the ''generic columns'' checkbox below the region source to proceed without parsing. ORA-00904: "SER_IS_ADMINYESNO": invalid identifier

  • Clarification on using function in where clause of oracle sql query

    I have an issue in regarding function using where clause of sql query..
    We are facing performance issue while executing query, so in what ways to improve the performance of the query which i have posted below.
    select col ,case when my_function(parameter)
    from tab1 a ,tab2 b,tabl3 c
    where a.column1=b.column2
    and b.column3 =c.column6
    and my_function(parameter)>0
    Regards
    Dinesh
    Edited by: wild fire on May 18, 2012 4:15 PM

    Dinesh,
    remind that when you use a function in the where clause it normally will get started for each record in the table.
    So your answer is two-fold:
    1. make the function only start when needed by adding a function based index on the table (this will make inserts and updates slower)
    2. make the function faster by adding the DETERMINISTIC clause if possible. this will make Oracle "cache" the result of the function.
    Regards,
    Richard
    blog: http://blog.warp11.nl
    twitter: @rhjmartens
    If this question is answered, please mark the thread as closed and assign points where earned..

  • How to create a filter using mathscript transfer function in labview

    Dear all,
    I am currently designing a filter in labview using a Mathscript looping. The filter can be represented in transfer function. I have attachted the transfer function equation together with its value and the desire frequency vs. amplitude graph that I should obtained from it. Also, following are the transfer function written in Matlab.
    B1= tf ([57.5221845],[1 51.017077 205.1868]);
    B2 = tf ([1 0],[7.6991]);
    B3 = tf ([1 0],[14.32433403]);
    B4 = tf ([1 0],[137.6017]);
    F = B1 * ( (1+B3)/((1+B2)*(1+B4)));
    plot(F)
    I have also modify the coding as Labview Mathscript does not support the Matlab coding "tf" as transfer function to "bilinear"
    Problem I am facing are:
    1) Unable to display the graph of the filter in labvie.
    2) Unable to have sinewave as an input to the filter.
    3) The output cannot be display in graph format. 
    Hope to have the soonest reply from you guys. Many thanks in advance 
    Solved!
    Go to Solution.
    Attachments:
    transfer function.jpg ‏18 KB
    Weighting Filter.vi ‏266 KB

    Thank you again for offering to help me in writing the code.
    I suppose that I should do a frequency sweep on the transfer
    function to prove that it behave as the sample graph. Example, if I have an input sine
    wave with the frequency of 8.8Hz passing through the transfer function filter, the
    output that I should be getting is 1 according to the transfer function graph
    and of cause the frequency range of my input sine wave would only be between
    the ranges of 0.5 Hz to 30 Hz.
    Attachments:
    Weighting FilterTest1.vi ‏53 KB

  • Using the result of a function, inside a subselect

    Hi!
    I´m wondering if it´s possible to use the result of a function inside a subselect. Let me give you an example of what I´m trying to do here:
    select * from t_node where node_pk in (get_node_parents_pk(22345));
    The function get_node_parents_pk stands in for the following SELECT-statment:
    select node_pk from t_node_child where parent_node_pk = 12345
    The statement above would return something like this: 12435,23423,23453,23452
    These values represent the node_pk value for the parent nodes.
    I want the get_node_parents_pk function to return a result set similar to this so that I might call it inside the IN ( ) statement.
    Any clue? =)

    I created a collection type in the database:
    CREATE OR REPLACE TYPE nodes_pk_arr IS TABLE OF INTEGER;
    The function get_node_parents_pk () is made to return the collection type above. However, this does not work. I get the following error message:
    SELECT *
    FROM t_node
    WHERE node_pk IN
    (SELECT * FROM TABLE (get_node_parents_pk (22345)));
    ORA-22905: cannot access rows from a non-nested table item
    However, if I insert a nodes_pk_arr collection directly into the SQL-statement, like I do below, it works:
    SELECT *
    FROM t_node
    WHERE node_pk IN
    (SELECT * FROM TABLE (nodes_pk_arr(24564,23545,34523));
    So, when returning the collection from the function I´m told that the collection is not a nested table, when in fact it is. What gives?
    Also, is there no way to return a result set directly from the get_node_parents_pk() function, making it possible to write the statement like that shown below?
    SELECT *
    FROM t_node
    WHERE node_pk IN (get_node_parents_pk (22345));
    Your reply is much appreciated!
    Kind regards
    Robert

  • Regd. using functions in where clause

    Hi All,
    I need to apply a set of functions in sysdate and use that in a where clause to compare. My question is, will these functions on sysdate be executed for every record in the tables that I use? Will this have performance impact when i have millions of records returned by the select?
    Below is the scenario:
    Select * from table A inner join table B on A.c1 = B.c1 where
    TO_NUMBER(TO_CHAR(TRUNC(LAST_DAY(ADD_MONTHS(SYSDATE, -1))),'YYYYMMDD')) BETWEEN Date1 and Date2
    Regards,
    Raj.D

    1005330 wrote:
    I need to apply a set of functions in sysdate and use that in a where clause to compare. My question is, will these functions on sysdate be executed for every record in the tables that I use? Will this have performance impact when i have millions of records returned by the select?
    Below is the scenario:
    Select * from table A inner join table B on A.c1 = B.c1 where
    TO_NUMBER(TO_CHAR(TRUNC(LAST_DAY(ADD_MONTHS(SYSDATE, -1))),'YYYYMMDD')) BETWEEN Date1 and Date2
    Test it on a small data set - run a query and check the execution plan to see what the predicate section tells you.
    Oracle OUGHT to be smart enough to recognise that you've got a constant that it need only calculate once. If not, then change the usage to read:
        (select TO_NUMBER(TO_CHAR(TRUNC(LAST_DAY(ADD_MONTHS(SYSDATE, -1))),'YYYYMMDD')) from dual) BETWEEN Date1 and Date2Note, by the way, that 'constant between col1 and col2' is generally a tough one as far as efficiency is concerned; it translates to:
        col1 <= constant
    and col2 >= constantIn many cases this means oracle has to access a large volume of data (for one of the predicates) and then filter that data (with the other predicate). A typical damage limitation strategy is to create an index on the two columns, arrangin the column order to minimise the range scan on the first column.
    Depending on your data patterns and the nature of the predicate there are alternative optimiisation strategies.
    Regards
    Jonathan Lewis

  • After F4 selection ,where can i filter the product result table

    I have created  F4 help for product search in Web U for extra field
    Component:PRD01QR and view:Search Help under context node :SEARCH..
    1)After selecting the value from f4,From where can i get the selected value inside the program
    2)How can i use this value to filter the product result table
    Please-help urgent

    I tried the above methods but still cant resolve..
    Am able to get the help value and internal table result. but when i put value to my custom field using f4 help and press search it going to this query
    OPEN CURSOR WITH HOLD lv_cursor FOR
             SELECT prod~product_guid
                    prod~logsys
                    prod~product_id
                    prod~product_type
                    prod~config
                    prod~xnosearch
                    prod~object_family
                    prod~batch_dedicated
                    prod~competitor_prod
             FROM  COMM_PRODUCT as prod   INNER JOIN COMM_PR_FRG_REL  as COMM_PR_FRG_REL0  on COMM_PR_FRG_REL0product_guid = prodproduct_guid  AND CO
             CLIENT SPECIFIED
             WHERE
                 prod~client      = sy-mandt                  AND
                 batch_dedicated  IN gt_batch_dedicated_range AND
                 competitor_prod  IN gt_competitor_range      AND
                 config           IN gt_config_range          AND
                 prod~logsys      IN gt_logsys_range          AND
                 object_family    IN gt_object_family_range   AND
                 product_id       IN gt_product_id_range      AND
                 product_type     IN gt_product_type_range    AND
                 (gt_where).
    here get_where has value
    ZSECTION_SET~ZZ0010 = 'S'
    which is my field value.At this point internal table is going blank and search fails.

  • Zoom function - my script on Hotmail is so small and Hotmail says use zoom function on browser, where do I find this?

    The script on Hotmail has suddenly gone small and won't get bigger. when I ask for help on hotmail, it says use zoom function on browser - where, how?

    Reset the page zoom on pages that cause problems: <b>View > Zoom > Reset</b> (Ctrl+0 (zero); Cmd+0 on Mac)
    *http://kb.mozillazine.org/Zoom_text_of_web_pages

  • Using function in where clause

    I have created a function as follows
    create or replace FUNCTION get_codes RETURN varchar2 IS
    scodes varchar2(50) := 'A1,A2';
    BEGIN
    scodes := '('''||REPLACE(scodes,',',''',''')||''')';
    return scodes;
    END;
    this function returns ('A1','A2')
    now i want to use this in where clause, both below statements fetches no rows
    select * from tablea where code in (select get_codes from dual);
    select * from tablea where code in get_codes;
    but the following will fetch rows
    select * from tablea where code in ('A1','A2')
    how to use function in where clause
    Thanks

    Hi,
    The code that works:
    where code in ('A1','A2')is testing whther code is either of two 2-character strings, A1 or A2.
    The ones that don't work, such as:
    where code in get_codes;are comparing code to one 9-character string: 'A1','A2', where characters 1, 4, 6 and 9 are single-quotes. (The function can only return one value.)
    You can use dynamic SQL to embed that 9-character string in part of your query, where it will be interpreted as two 2-character strrings.
    [Oracle Base|http://www.oracle-base.com/articles/misc/DynamicInLists.php] and AskTom have good pages on the subject of dynamic IN-lists.
    Of you can use INSTR or LIKE:
    where INSTR ( get_codes
                , '''' || code || ''''
                ) > 0

  • TS1717 I have today purchased an iPod nano. I am using Widows 7. When I try to register the iPod I get the message that " iTunes has stopped working" I have reinstalled iTunes with the same result. Where do I go from here?  Brian.

    I have today purchased an iPod nano (gen 6); I use Windows 7. Am trying to register my iPod but each time I submit required info I get the message "iTunes has stopped working". I have reinstalled iTunes with same result. Where do I go from here?
    Brian

    Hello notime4,
    The article linked below details some useful troubleshooting steps that can help stabilize iTunes on your computer.
    iTunes for Windows Vista, Windows 7, or Windows 8: Fix unexpected quits or launch issues
    http://support.apple.com/kb/TS1717
    Cheers,
    Allen

  • HT4753 I have a very simple question: how do I view where Lion has autosaved my current version to (without the convoluted route of using finder)? In days gone by i'd simply use the save as function to see where it was being saved.

    I have a very simple question: how do I view where Lion has autosaved my current version to (without the convoluted route of using finder)? In days gone by i'd simply use the save as function to see where it was being saved.

    It's actually even easier than using Save As to see the full path to the currently open document. Just do a "Secondary click" on the document title in its window's title bar.
    Like you, I relied upon Save As my whole life to check a file's location and considered it a must-have capability. Turns out it's even faster to use the single-click method to reveal the full path to the open document. It displays the entire path to the current document starting from the level of your Mac, and works for files stored on drives as well as iCloud.
    If you're not sure how to do a secondary click, go into System Preferences, select Trackpad, Point & Click to find the current preference for secondary click on your Mac. If you happen to have a mouse with more than one button, it's probably the right button. As a trackpad user, I check the box to "Click or tap with two fingers," so a simple two finger tap on the title of an open document reveals its full path. This feature actually has been around for a very long time.
    Note that this is not the same thing as the Autosave and Versions menu, which is exposed using a little drop down triangle to the right of the title. There is no visual clue for the presence of this feature - you just have to know it's there, probably because this feature goes all the way back to pre-OS X days.

  • How to use a function in a Where Clause?

    Hi,
    I've got a doubt. If MY_FUNCT is a function that returns a boolean, can I use it in a where clause for writing a query like this?:
    select ...
    from table a
    where ...
    and MY_FUNC (a.field) = true
    Thanks!
    Edited by: Mark1970 on 2-lug-2010 3.27

    Bear in mind that this could kill your performance.
    Depending on what you're doing, how many tables and other predicates are involved, you might want to try to eliminate all other data early before applying your function predicate otherwise your function might be called more times than you might have imagined. Strategies for this include subquery factoring and the old ROWNUM trick for materialising an inline view.
    If performance is impacted, you might also want to consider using a function-based index provided that the function is deterministic.

  • Able to install the .ipa signed with distribution certificate using iTunes on MacBook Pro. where as the when tried to install using iTune on PC is causing a problem

    Able to install the .ipa signed with distribution certificate using iTunes on MacBook Pro. where as the when tried to install using iTune on PC is causing a problem

    The sound input going to the mic is not going to pipe through the speakers like that.  It doesn't do it because it would cause a feedback loop on itself.  The mic input will take sound and output it to a program or to another pathway (like a VoIP or Facetime call, etc.) but it won't behave like a Karaoke machine if that's what you're thinking.

  • Using ASSOCIATED on a function result

    I'm having trouble using the ASSOCIATED intrinsic with the result of a function. It appears to work in Studio 12 but in 12.2 I get a segfault. The problem happens when the result of a function is set to null. It appears that the function result pointer somehow becomes undefined (but I'm not sure). For example the following sample program gives a segfault in Studio 12.2:
    double precision, pointer :: input=>null()
    if (associated(getY(input)) then
    print*, "associated"
    else
    print*, "not associated"
    endif
    contains
    function getY (y) result (yResult)
    double precision, pointer :: y
    double precision, pointer :: yResult
    yResult => null()
    if (associated(y)) then
    yResult=>y
    endif
    end function getY
    If however if first associate a new local variable with the function result (x=>getY(input)) I don't get a segfault when calling associated(x). Any ideas on why this happens or if I'm doing something wrong?

    I apologize for taking so long to respond.
    After modifying your code slightly so that it would compile, I was able to reproduce the problem using the Oracle Solaris Studio 12.2 release. When I compile the program with the beta compiler for release 12.3, it works correctly. The output is
    not associated
    I hope the problem has been resolved.
    Robert Corbett

  • The datediff function resulted in an overflow. The number of dateparts separating two date/time instances is too large. Try to use datediff with a less precise datepart.

    The below function is giving me the hours difference what I wanted, but today it is giving us the below error: 
    Msg 535, Level 16, State 0, Line 1
    The datediff function resulted in an overflow. The number of dateparts separating two date/time instances is too large. Try to use datediff with a less precise datepart.
    Please Help..
    ALTER FUNCTION [dbo].[GetHoursExcludingWeekdays](@StartDate datetime2,@EndDate datetime2)
    returns decimal(12,3)
    as
    begin
        if datepart(weekday,@StartDate) = 1
            set @StartDate = dateadd(day,datediff(day,0,@StartDate),1)
        if datepart(weekday,@StartDate) = 7
            set @StartDate = dateadd(day,datediff(day,0,@StartDate),2)
        -- if @EndDate happens on the weekend, set to previous Saturday 12AM
        -- to count all of Friday's hours
        if datepart(weekday,@EndDate) = 1
            set @EndDate = dateadd(day,datediff(day,0,@EndDate),-2)
        if datepart(weekday,@EndDate) = 7
            set @EndDate = dateadd(day,datediff(day,0,@EndDate),-1)
        declare @return decimal(12,3)
        set @return = ((datediff(second,@StartDate,@EndDate)/60.0/60.0) - (datediff(week,@StartDate,@EndDate)*48))
        return @return
    end
    ReportingServices

    You'll get this error if the difference between the start and end date is greater that about 68 years due to the "second" DATEDIFF specification.  Perhaps the dates are greater than the expected range due to a data quality issue. 
    Taking the advice from the error message, you could use minutes instead of seconds like the example below the version below.  This could still result in the error of the difference is greater than a couple of hundred years, though.  You might consider
    validating the dates and returning NULL if outside expected limits.
    ALTER FUNCTION [dbo].[GetHoursExcludingWeekdays](@StartDate datetime2,@EndDate datetime2)
    returns decimal(12,3)
    as
    begin
    if datepart(weekday,@StartDate) = 1
    set @StartDate = dateadd(day,datediff(day,0,@StartDate),1)
    if datepart(weekday,@StartDate) = 7
    set @StartDate = dateadd(day,datediff(day,0,@StartDate),2)
    -- if @EndDate happens on the weekend, set to previous Saturday 12AM
    -- to count all of Friday's hours
    if datepart(weekday,@EndDate) = 1
    set @EndDate = dateadd(day,datediff(day,0,@EndDate),-2)
    if datepart(weekday,@EndDate) = 7
    set @EndDate = dateadd(day,datediff(day,0,@EndDate),-1)
    declare @return decimal(12,3)
    set @return = ((datediff(minute,@StartDate,@EndDate)/60.0) - (datediff(week,@StartDate,@EndDate)*48))
    return @return
    end
    GO
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

Maybe you are looking for