Referencing Aggregated Column Value in Where Clause

Hello -
I'm trying to determine how I can accomplish the following in the most straightforward, efficient way.
Among other things, I'm selecting the following value from my table:
max(received_date) as last_received_dateI also need to evaluate the "last_received_date" value as a condition in my where clause. However, I can't reference my aliased "last_received_date" column value, and when I try to evaluate max(received_date) in the where clause, I get the "group function is not allowed here" error.
Does anyone know of a good workaround?
Thanks,
Christine

Hi,
Column aliases can be used in the ORDER BY clause: aside from that, they cannot be used in the same query where they are defined. The workarounds are
(a) define the alias in a sub-query, and use it in a super-query, like Someoneelse did, or
(b) repeat the aliased expression, as in the HAVING-clause, below.
Aggregate functions are computed after the WHERE-clause. (That explains why you can do things like
SELECT  MAX (received_date) last_received_date_2008
FROM    table_x
WHERE   TO_CHAR (received_date, 'YYYY')  = '2008';).
The HAVING-clause is like the WHERE-clause, but it is applied after the aggregate functions are computed, e.g.
SELECT    deptno
,         MAX (recieved_date)  AS last_received_date
FROM      table_x
GROUP BY  deptno
HAVING    MAX (received_date)    > SYSDATE - 7   -- Only show deptartments with activity in the last week
;

Similar Messages

  • "create columns with a where clause" in BMM

    Hi All,
    I have a question about OBI EE Meta data layer.
    We have OBIEE sitting on a Data Warehouse with a star schema.
    Our Fact table holds the following fields...
    EmployeeID
    CompanyID
    Measure ID
    Measure Name
    MEASURE
    This is what we have in the physical layer, BMM layer and the presentation layer but I want to be able to "create columns with a where clause"
    So my fact table in the presentation layer would look like this
    Amount Sold
    Unit Cost
    Company Amount
    I thought I could just create a logical column with
    Amount Sold = Measure
    where Measure Name = "Amount Sold"
    But I can't seem to find any to do that.
    Any ideas?
    Thanks

    Or you simply map your measure in the Logical Table source as something like :
    CASE WHEN MEASURE_NAME = 'Amount Sold' THEN MEASURE ELSE 0 END.
    You need to decide if you want the where clause adding in the Logical table source (be careful you will need a seperate LTS for each measure, this will mean more than one SQL being fired when you have more than one measure in the report).
    Or you go with this case method on each measure, be able to have all the measures mapped in 1 LTS, include all those in the report and they will be retrieved by one SQL block.

  • Problem with column alias: Unknown column 'avg_rating' in 'where clause'

    Hello,
    I have a basic sql statement as follows:
    SELECT
    e.establishment_id,
    e.establishment_name,
    avg(r.rating) avg_rating
    FROM
    establishment e,
    rating r,
    comment com,
    establishment_country ec,
    country_ref cou
    where
    etc...
    and avg_rating >= 1
    and 0=0
    group by e.establishment_id
    order by e.establishment_idI have used a column alias for "avg(r.rating)" and named it "avg_rating".
    It works in my Mysql Query browser without problem but when I run it from Java I get this:
    java.sql.SQLException: Unknown column 'avg_rating' in 'where clause'
        at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:2928)
        at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1571)
        at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1666)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:2988)
        at com.mysql.jdbc.Connection.execSQL(Connection.java:2917)
        at com.mysql.jdbc.Statement.executeQuery(Statement.java:824)
        at org.jboss.resource.adapter.jdbc.WrappedStatement.executeQuery(WrappedStatement.java:145)
        at arcoiris.SearchSessionBean.performSearch(SearchSessionBean.java:73)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
        at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionContainer.java:214)
        at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionInterceptor.java:149)
        at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstanceInterceptor.java:154)
        at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor.java:54)
        at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
        at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
        at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
        at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
        at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:153)
        at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
        at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:122)
        at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
        at org.jboss.ejb.Container.invoke(Container.java:873)
        at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:415)
        at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:88)
        at $Proxy172.performSearch(Unknown Source)
        at arcoiris.SearchManagedBean.performSearch(SearchManagedBean.java:171)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at com.sun.faces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:126)
        at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:72)
        at javax.faces.component.UICommand.broadcast(UICommand.java:312)
        at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:267)
        at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:381)
        at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:75)
        at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:200)
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:90)
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:197)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
        at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
        at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:159)
        at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
        at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
        at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
        at java.lang.Thread.run(Thread.java:595)Can anyone help please?
    Thanks in advance,
    Julien Martin.

    I am having the similiar problem, the query in java creator IDE works fine after i upgraded the J-connector and changed DataSource type for MySQL to mysql-connector-java-5.0.4-bin.jar. but still i cannot bind any control in the form to the aliased column. this is really frustrating. can anyone from Sun Developer explain?
    THX

  • "Invalid Column" on multiple where clauses with subqueries and cfqueryparam

    I'm seeing a behavior in the coldfusion cfquery that I'd like to find an exmplanation for .  I've got a query that does a subquery in the select portion and if I have multiple where lines, I get an "invalid column name" message for my second where clause, but only when I'm using cfqueryparam
    For example on the following I get "Invalid column name 'position_id'"
    SELECT   department_staff_tbl.*,
             (   SELECT   max(bookmark_id)
                 FROM     bookmarked_items_tbl
                 WHERE    item_id = department_staff_tbl.staff_id
             ) AS bookmark_id
    FROM     department_staff_tbl
    WHERE    department_id = <cfqueryparam value="#arguments.deptid#"  cfsqltype="cf_sql_integer">
    AND     position_id   = <cfqueryparam value="#arguments.posid#"   cfsqltype="cf_sql_integer">
    AND     staff_id      = <cfqueryparam value="#arguments.staffid#" cfsqltype="cf_sql_integer">
    If I change the order of my where clause so staff_id is first, then it tells me "department_id" is an invalid column.
    If I only have one where clause, it works.  (i.e. WHERE position_id = <cfqueryparam value="#arguments.posid#" cfsqltype="cf_sql_integer">).
    If I remove the where clause from my subquery (WHERE     item_id = department_staff_tbl.staff_id) it works.
    It also works if I remove the cfqueryparam from my where clause so that my query looks like this:
    SELECT   department_staff_tbl.*,
             (   SELECT   max(bookmark_id)
                 FROM     bookmarked_items_tbl
                 WHERE    item_id = department_staff_tbl.staff_id
             ) AS bookmark_id
    FROM     department_staff_tbl
    WHERE    department_id = #arguments.deptid#
    AND     position_id   = #arguments.posid#
    AND     staff_id      = #arguments.staffid#
    Any thoughts?

    I see two tables. So can the server. So, use qualified column-names.
    SELECT   department_staff_tbl.*,
             (   SELECT   max(bookmarked_items_tbl.bookmark_id)
                 FROM     bookmarked_items_tbl
                 WHERE    bookmarked_items_tbl.item_id = department_staff_tbl.staff_id
             ) AS bookmark_id
    FROM     department_staff_tbl
    WHERE    department_staff_tbl.department_id = <cfqueryparam value="#arguments.deptid#"  cfsqltype="cf_sql_integer">
    AND      department_staff_tbl.position_id   = <cfqueryparam value="#arguments.posid#"   cfsqltype="cf_sql_integer">
    AND      department_staff_tbl.staff_id      = <cfqueryparam value="#arguments.staffid#" cfsqltype="cf_sql_integer">

  • Concatenation error - when i use text column value in where condition.

    Hi,
    i am creating Materialized view using few columns from two tables and as per requirement i need to prepare select statement with where condition in another column.(new column)
    i tried like below....
    create materialized view MAIN
    refresh force on demand
    as
    select
    a.table_name,
    a.column_name,
    b.trial_name,
    'select * from '||a.table_name||' where '||a.column_name|| ' = '|| b.trial_name||';' "QUERY"
    from
    exp_csv_tB a,
    exp_csv_tr b;
    a.table name value is : monitoring_table
    a.column_name value is : study
    b.trial_name = fty777
    Materialized view created with extra column but it is not added '' (codes) to text value in where condition.
    output which i got is :
    select * from monitoring_table where study = fty777;
    but
    i need output like
    select * from monitoring_table where study = 'fty777';
    fty777 value should be in codes like 'fty777'. i read some articles but didnt get this example.
    please help.

    Try this:
    CREATE MATERIALIZED VIEW main
    REFRESH FORCE ON DEMAND
    AS
    SELECT
    a.table_name,
    a.column_name,
    b.trial_name,
    'select * from '||a.table_name||' where '||a.column_name|| ' = '''|| b.trial_name||'';'' "QUERY"
    FROM
    exp_csv_tb a,
    exp_csv_tr b;
    You have to give double single codes for semi-colons ..
    Regards..

  • Passing check box values to WHERE clause

    Hi,
    I have created a Data block - 'CONTACTS' (Database data block)
    and has database item - 'Code', 'Descr'
    The number of records displayed is set to 5.
    Value When checked - 'Y'
    Value When Unchecked - 'N'
    Check box mapping of other values - 'unchecked'
    I am writing the code inside 'WHEN BUTTON PRESSED'. My main objective is to return the count of records based
    based on several conditions and one among them is CODE which is can be single or multiple based on the check box checked.
    The requirement is when i check one or multiple checkboxes, i should pass the 'Code' item values to the WHERE clause.
    Right now whenver i am trying to do so, only the current record value is copied to the WHERE clause.
    I have tried using basic loop but things havnt worked.
    Logic tried with basic LOOP
    BEGIN
    GO_BLOCK('CONTACT');
    IF :contact.cb = 'Y' THEN
    LOOP
    IF p_where is null then
    p_where := :contact.code;
    else
    p_where := p_where ||','||:contact.code;
    end if;
    exit when :system.last_record = 'TRUE';
    next_record;
    END LOOP;
    end if;
    MESSAGE ( 'p_where :'||p_where);
    MESSAGE (' ');
    END;
    And Even if i write the LOOP before the first IF, it return me the current record value and move to the last record.
    please guide me where am i wrong.
    Regards.
    Anoop.

    Try something like this:
    FIRST_RECORD;
    LOOP
      IF :contact.cb = 'Y' THEN
        IF p_where is null then
           p_where := :contact.code;
         else
           p_where := p_where ||','||:contact.code;
         end if;
       END IF;
      exit when :system.last_record = 'TRUE';
      next_record;
    END LOOP;
    -- END LOOP;
    MESSAGE ( 'p_where :'||p_where);
    MESSAGE (' ');
    END;

  • How to dynamically update columns in a where clause to a SQL query in OSB?

    Hi Gurus,
    I have a requirement where in we need to dynamically update a where clause to a SQL query in OSB(11.1.1.6.0).
    For example:
    If the JCA sql string is "select * from emp where emp_id = 100 and emp_status ='Permanent'" now i want to change this where clause and the new query has to be like "select * from emp where emp_name like 'S%' and emp_dept like 'IT' ". basically we need to change the where clause dynamically.
    We can also use "fn-bea:execute-sql()" in a xquery but I don't want to use this function as creates a new connection.
    I have done some home work and found out --> as per the DOC "http://docs.oracle.com/cd/E23943_01/dev.1111/e15866/jca.htm#OSBDV943" section: "25.5.2 JCA Transport Configuration for Proxy and Business Services", when a business service is created by using JCA, we can see Interaction Spec Properties under JCA Transport Tab. This will have a property "SqlString' and we can over ride it. But I am unable to figure out how to over ride the value. I have tried by using Transport Headers activity but no luck. Please guide me how to achieve this?
    Thanks in advance
    Surya

    I solved my problem.
    In my header renderer, I simply added a line to set the text to the object value "label.setText( (String) value );" (where label is an instance of a JLabel.
    Thank you to who took some time to think about it.
    Marc

  • Setting bind values in where clause in ViewObjectImpl

    We want customize our views in a special manner. To look up for instance a text in the session langauge, we add a bind variable to the declared where clause of a VO:
    and text.lang = :lang
    Let's suppose, the actual value of the session language be known within ViewObjectImplementations. I want to set the bind value transparently within the ViewObjectImplementation rather than having to do it in every UI related client using this VO. Until now, I set the bind value whenever getViewObject or BuildWhereClause is called. This is sufficient for the AM Tester, but not for JClient forms using this VO (as a Not-all-values-bound exception is thrown), and I am not able to figure out by the documentation which methods of a VO are called when it is created and queried by a JClient form.

    See this web log posting on providing automatic default values for VO bind variables:
    http://radio.weblogs.com/0118231/2003/08/01.html#a127

  • Javascript - Referencing report column value

    Hi,
    In my application I have a report "Test" with some columns. In column "PFT_PCODE" the possible values are either 1 or 2.
    What I want is to display the report table cell in red, if the value in "PFT_PCODE" is 1, or the table cell in orange, if the value in "PFT_PCODE" is 2, respectively.
    I tried to make something in Javascript, based on a Vikas' example. I put in the
    Region Header:
    <style type="text/css">
    .rot {
    background-color: red;
    .orange {
    background-color: orange;
    </style>
    Region Footer:
    <script type="text/javascript">
    var spans=document.getElementsByTagName('span');
    for (var j=0;j<spans.length;j++) {
    if (spans[j].className=='farbe') {
    var td=html_CascadeUpTill(spans[j],'TD');
    if (document.getElementsById('#PFT_PCODE#').value == 1) {
    td.className = 'rot';
    else {
    td.className = 'orange';
    </script>
    The column "PFT_PCODE" is marked as CSS class "farbe".
    Unfortunately it's not working, I'm not sure if I reference the report column value right. Since I'm a beginner in Javascript I would be glad for help.
    I put my (reduced) application on apex.oracle.com for testing.
    Workspace: app
    Login: [email protected]
    PW: riponi
    Thanks in advance,
    Roger

    Hi Roger,
    In your report, if you do a View Source, do your report headers have id's on them - that is, the TH tags that contain the headings?
    If so, you could use:
    &lt;script type="text/javascript"&gt;
    function hilite(f1)
    var h = document.getElementById(f1);
    var t = h.parentNode;
    while (t.tagName != 'TABLE')
      t = t.parentNode;
    var rows = t.rows;
    var k;
    var j;
    var c;
    var headers = t.getElementsByTagName("TH");
    for (k = 0; k &lt; headers.length; k++)
      if (headers[k].id == f1)
        c = k;
    for (k = 1; k &lt; rows.length; k++)
      j = rows[k].getElementsByTagName("TD")[c];
      if (j.innerHTML == '2')
        j.style.backgroundColor = 'purple';
        j.style.color = 'yellow';
      if (j.innerHTML == '1')
        j.style.backgroundColor = 'red';
        j.style.color = 'white';
    &lt;/script&gt;Put that in the page's HTML Headers setting.
    In the report region's Region Footer, add in:
    &lt;script type="text/javascript"&gt;
    hilite('PFT_PCODE');
    &lt;/script&gt;This will find the heading's TH cell, work out where it is in the row, then loop through all remaining rows and check the TD cell in the same column, highlighting the cell using background and font colours.
    Andy

  • Multiple values in where clause(IN) of select query in Cisco Cloud Portal using single field

    I can actually pass multiple values in the IN statement of select query using multiple dictionary fields in the data retrieval rule of the AFC in Cisco cloud portal like
    #dictionary.field1# = 1 and
    #dictionary.field2#=2
    select col1,col2 from table1 where col3 in (#dictionary.field1#,dictionary.field2#).
    but I want to pass mutiple values in a single field as
    #dictionary.field1#=1,2
    select col1,col2 from table1 where col3 in (#dictionary.field1#) and the query gives no data because it is taking as '1,2' instead of '1','2'.
    Please give the solution for passing multiple values in a single variable to use in IN operator of WHERE clause

    Ok, I now understand what you are trying to do. Unfortunately, you cannot inject parts of a SQL statement into a DDR through a dictionary field, which always represents a specific value (the comma in your case is attempting injection of a SQL construct to refer to multiple values). One possible solution is to arbitrarily consolidate your list of values using a delimiter that you know will not be in the values themselves such as a colon (:). Let's use 3 values as it serves as a better example.
    Set your dictionary field to a single reference to all 3 values of interest, say 'a', 'b', 'c' as:
    :a:b:c:  (you can use javascript to create this consolidated dictionary field)
    Now your query would look something like the following:
    select col1,col2 from table1 where #dictionary.field1t# like '%:'+col3+':%'
    This should achieve the desired result.

  • Please Help: query matching string value in WHERE clause

    Hi Everyone,
    I am trying to query customers that has matching first and last name but, I am getting result of every customer that has first and last name. Here is what my query looks like:
    SELECT * FROM  CUSTOMERS WHERE
    CUSTOMER_FNAME IN
    'JOHN', 'MIKE'
    AND CUSTOMER_LNAME IN
    'DOE', 'MILLER'
    ); I am trying to query customer name that is JOHN DOE and MIKE MILLER but, i get result of all names that has the first/last names not exact match. Is there way i can do that get exact match?
    Thanks,
    SM

    Frank Kulash wrote:
    Hi,
    chris227 wrote:
    SMCR wrote:
    Thanks everyone for your help!
    There are two correct answers, I am using following:I just see one, it's Franks.If fname never contains a '~' (or if lname never contains a '~") then
    {code}
    where fname||'~'||lname in ('JOHN~DOE', 'MIKE~MILLER');
    {code}
    will work.Yes, I realized that. For the purpose i am using i will not have any issue with '~'
    I did however changed it up a little, here is how it looks like:
    {code}
    SELECT CUSTOMER_ID, CUSTOMER_FNAME, CUSTOMER_LNAME, DATE_OF_BIRTH
    FROM CUSTOMERS
    WHERE (CUSTOMER_FNAME||'~'||CUSTOMER_LNAME, DATE_OF_BIRTH) IN
    (('JOHN~DOE'), (TO_DATE('20130101', 'YYYYMMDD'))),
    (('MIKE~MILLER'), (TO_DATE('20130101', 'YYYYMMDD')))
    {code}

  • Is it possible to use LONG columns in WHERE clause or ORDER BY?

    Is it possible to use LONG columns in WHERE clause or ORDER BY?

    Hi,
    LONG data type is deprecated, maybe could you change your column type to LOB ?
    Nonetheless below is a workaround which may fit your needs if forced to use LONG.
    It uses a function which returns you a CLOB. It allows you to use the converted "LONG" column in a WHERE clause.
    Then if you want to order by you have to convert the CLOB to a VARCHAR using DBMS_LOB.SUBSTR.
    SQL> CREATE TABLE my_table (id NUMBER, description LONG);
    Table created.
    SQL> INSERT INTO my_table VALUES (1, 'FIRST LONG');
    1 row created.
    SQL> INSERT INTO my_table VALUES (2, 'ANOTHER LONG');
    1 row created.
    SQL> COMMIT;
    Commit complete.
    SQL> CREATE TYPE my_type_row AS OBJECT (id INTEGER, description CLOB);
      2  /
    Type created.
    SQL> CREATE TYPE my_type_table AS TABLE OF my_type_row;
      2  /
    Type created.
    SQL> CREATE OR REPLACE FUNCTION get_my_long
      2     RETURN my_type_table
      3     PIPELINED
      4  AS
      5     v_tab   my_type_table := my_type_table ();
      6  BEGIN
      7    FOR cur IN (SELECT id, description FROM my_table)
      8  LOOP
      9        PIPE ROW (my_type_row (cur.id, cur.description));
    10  END LOOP;
    11  RETURN;
    12  END;
    13  /
    Function created.
    SQL> SELECT
      2     id,
      3     description
      4  FROM
      5     TABLE (get_my_long ())
      6  WHERE
      7     description LIKE '%LONG'
      8  ORDER BY
      9     DBMS_LOB.SUBSTR(description);
      ID DESCRIPTION
       2 ANOTHER LONG
       1 FIRST LONG
    SQL> SELECT
      2     id,
      3     description
      4  FROM
      5     TABLE (get_my_long ())
      6  WHERE
      7     description LIKE 'FI%';
      ID DESCRIPTION
       1 FIRST LONG
    SQL>Kind regards,
    Ludovic

  • Performance Tuning on a table where WHERE clause is having only PK columns

    Hi folks!!
    Here is the gotcha!!!!
    I am having a table, named X, with primary key columns A and B.
    I running a packaged procedure in which there is a SELECT statment to get the record from the table X with WHERE condition on A and B columns. Now the problem is, the package is taking too much amount of time to get executed.
    Eventually, I used TKPROF utility on the trace file of that package execution.
    The trace file is showing that huge amount of time is spent on the SELECT statement of table X, as I said above.
    I am baffled why it is taking that much of time eventhough the columns in the WHERE clause are Primary Key columns only and that too there are in the sequential order as that of in primary key contituent sequence.
    I would be very grateful to you guyz... plz help me out of this one....
    Cheers...........PCZ

    Also can you use preformatting as requested above, so
    that we can read it?
    [pre]Your preformatted
    text[/pre]
    Hi William,
    Plz find the requested:
    SELECT *
    FROM
    STTMS_CUST_ACCOUNT WHERE BRANCH_CODE=:B2 AND CUST_AC_NO=:B1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse      180      0.00       0.04          0          0          0           0
    Execute  56538      0.96       4.02          0          0         26           0
    Fetch    56512   5581.98   19547.83         12 1134505869          6       56512
    total   113230   5582.94   19551.89         12 1134505869         32       56512
    Misses in library cache during parse: 0
    Optimizer mode: ALL_ROWS
    Parsing user id: 42  (FLEXMIG)   (recursive depth: 1)
    Rows     Row Source Operation
        325  TABLE ACCESS BY INDEX ROWID STTM_CUST_ACCOUNT (cr=6427406 pr=1 pw=0 time=327599336 us)
    10064925   INDEX RANGE SCAN IND_DORMANCY (cr=46475 pr=0 pw=0 time=15740976 us)(object id 512984)
    Rows     Execution Plan
          0  SELECT STATEMENT   MODE: ALL_ROWS
        325   TABLE ACCESS   MODE: ANALYZED (BY INDEX ROWID) OF
                  'STTM_CUST_ACCOUNT' (TABLE)
    10064925    INDEX   MODE: ANALYZED (RANGE SCAN) OF 'IND_DORMANCY' (INDEX)
    ********************************************************************************This is what I can do. I apologize if it still does not come out in proper format. This is the first time I am trying it. :)
    Cheers.......PCZ

  • Column Security - Users can't see it, but need to use it in the query WHERE Clause

    I am looking at possible solutions (if any) on column security. We need to be able to restrict users from seeing certain columns, however, they will need these columns in the WHERE clause of queries.
    I thought about creating views, however, it would be a poor database design. Is there any way that this can be done on the database level. I know about Fine Granular Access Method, however, this just excludes the column completely. Which means that they can not be used in the WHERE clause.
    Any help would be greatly appreciated.
    Philip

    I too added 2nd apple ID when I tried to get Free app from apple store just to get to NONE on the credit card needed. It said it sent confirmation email to my new apple ID email that I have to confirm. Problem is I can not get to the new apple ID email account.  On my ipad it logs into my original email account and I see no where to log into another email account.  If I go to my laptop, the new apple ID I created does not let me log into email where apple said it was sent to.  It did not send to back up email account either.
    Can I log into 2 email accounts on my ipad where it says mail at bottom?
    Can I have 2 apple ids?
    If I created a 2nd apple id to get to NONE on credit card needed, can't I log into it also on another laptop in gmail?
    (won't let me)
    If I used my original apple id I created when I got my new ipad, it will not let me get free app without credit card, there is no where it says NONE needed. I am too new to apple to start with credit cards etc until I get use to it.

  • Checkbox Value in where condition of query

    Hi,
    I have a check box which shows values based on the LOV's . If i check on the checkbox the values that are selected on the check box must be used in the where condition to update the table.
    Please suggest me how to take the check box values.
    Am using the below methos to update but its not happening
    Declare
    old_cohort_name varchar2(500);           
    new_cohort_name varchar2(500);
    l_cohort_id apex_application_global.vc_arr2;
    begin
    l_cohort_id := apex_util.string_to_table(:P64_CASCADE_COHORT_NAMES);
    select cohort_name into old_cohort_name from study_cohort
    where cohort_id = :p64_cohort_id;
    select :P64_COHORT_NAME into new_cohort_name from dual;
    if old_cohort_name <> new_cohort_name then
    update study_cohort
    set      
    cohort_name = new_cohort_name
    where cohort_id = :p64_cohort_id and
    cohort_id = l_cohort_id; // here is the variable i am using when checkbox is checked
    End if;
    End;
    Please suggest me how to modify the code
    Tx
    Sudhri

    Hi Sudhri,
    where cohort_id = :p64_cohort_id and
    cohort_id = l_cohort_id; // here is the variable i am using when checkbox is checked If this is the code you are actually using, then the condition would only be met if l_cohort_id = :p64_cohort_id because you are using an AND condition over the same column in the where clause, so it will only return rows when both values are the same. Then, I think that it seems not to be working for you because :p64_cohort_id and l_cohort_id have different values, and no row is getting updated then. If the values you are selecting in your checkboxes are several ids of rows to update, besides the one with id :p64_cohort_id, then maybe the condition you need is something like this:
    WHERE cohort_id = :p64_cohort_id OR instr(l_cohort_id, cohort_id) != 0;Hope that helps.
    Regards,
    Sergio

Maybe you are looking for

  • Adobe Printer Configurations

    does anyone know how to configure acrobat standard to print archC (18x24) and archD (24x36) pages so that when creating a PDF from autoCAD it recognizes the paper size?

  • Stacking photo albums on iPad

    I've always had the impression one can stack albums on the ipad but can't make it happen. In iphoto I created a folder. In that folder I placed a few albums. But they just all appear as seperate albums when I sych. I'd like to have a stack called hea

  • MSEXchange not rejecting bad email addresses

    I have written a specialized email application In ACCES 2010 for my department. At first I couldn't send email outside our domain so the server folks turned on relay and gave me a static IP address. However, now the mail server does not reject bad em

  • G4 Cube Suddenly Shuts Down without Warning

    I have a G4 Cube (450/1.5GB/60GB/Airport) which has behaved perfectly (it's eerily quiet) until the past few days when it has started cutting out completely and abruptly without warning--as if you unplugged the power supply. The memory and hard drive

  • A grey filter seems to cover my RAW images after importing.

    First, I import RAW images from my Nikon 1 v2. When I start to look at the images at first they appear clear and bright. Within a second it seems that a light grey filter descends over the image, making it look dully and blah. RAW tends to look a bit