Shot summary of a where condition clause...

I have a form that displays the code material and this number in which different warehouses...

It is possible to create an element of the summary screen is based on the place where the condition

for ex.
SQL> select  sum(arar) from tbs;

 SUM(ARAR)
----------
      1488

for this query i can create a  display item and in the propery  pallete  i can select mode as summary,
summary function as count, and select respective block and item...

what i want to know is can this be based on where condition 
some thing like the count shoudn't include where the column values is zero
SQL> select count(arar) from tbs where arar!='0';

COUNT(ARAR)
-----------
        144
Published by: Chase Suhail on November 9, 2010 22:45

Hello

Create a column of formulas no database in the same block to say 'NON_ZERO.
The formula for the column would be: SET_NON_ZERO - this function returns 1 if arar is non-zero and 0 if it is zero.

FUNCTION SET_NON_ZERO RETURN NUMBER IS
BEGIN
 IF :ARAR = 0 THEN
   RETURN (0);
 ELSE
   RETURN (1);
 END IF;
END;

Now you can create a column of synthesis and use the text-to-speech function 'sum' and item summarised as "NON_ZERO.

I hope this helps.

Best regards

Arif Khadas

Tags: Oracle Development

Similar Questions

  • Based where conditional clause...

    dear team,
    i have following code..
    
    Declare
      gv_flag1 Varchar2(1)   := 'N';
      gv_flag2 Varchar2(1)   := 'N';
      gv_flag3 Varchar2(1)   := 'N';
      all_where1       Varchar2(250);
      all_where2       Varchar2(250);
      ALL_where3       Varchar2(250);
      V_QTY           Number;
    Begin
      If gv_flag1 = 'N' Then
         all_where1 := 'AND '||'V.OWNER = ''PROD''';
      End If;
      DBMS_OUTPUT.PUT_LINE(all_where1);
      
      If gv_flag2 = 'N' Then 
         all_where2 := 'AND '||'V.OPERATION NOT LIKE (''10%'')';
      End If;   
      DBMS_OUTPUT.PUT_LINE(all_where2);
      
      If gv_flag3 = 'N' Then
         all_where3 := 'AND '||'V.OPERATION NOT LIKE (''07%'')';
      End If;
      DBMS_OUTPUT.PUT_LINE(all_where3); 
       
      --select based on conditions..
    End; 
    
    NOW I want where conditions in select statment to be conditional...
    
    which means if flag1='N' and flag2 = 'N' then use both all_where1 and all_where2 in *where* clause statement...
    if flag1='N' and flag3 = 'N' then then use all_where1 and all_where 3 in *where* clause of select statement...
    if all there flag = 'N' then use all_where conditions in *where* clause of select statement...
    
    i have 3 flags, which means total of 9 combinations,  is there any simpler way to do such kind of thing??
    
    please assist me
    
    nic

    Nicloei W wrote:
    Hi Jeenesh,

    What happens if Flag2 = 'Y' and Indicateur3 = 'Y' in this case, I want only the condition with Flag1

    concerning
    NIC

    SQL> ed
    Wrote file afiedt.buf
    
      1  Declare
      2    gv_flag1 Varchar2(1)   := 'N';
      3    gv_flag2 Varchar2(1)   := 'Y';
      4    gv_flag3 Varchar2(1)   := 'Y';
      5    --all_where1       Varchar2(250);
      6    --all_where2       Varchar2(250);
      7    --ALL_where3       Varchar2(250);
      8    lc_query varchar2(1000):= 'select count(*) from test v ';
      9    lc_where varchar2(500) := ' where 1 = 1 ';
     10    V_QTY           Number;
     11  Begin
     12    If gv_flag1 = 'N' Then
     13       lc_where := lc_where||' AND V.OWNER = ''TEST''';
     14    End If;
     15    If gv_flag2 = 'N' Then
     16       lc_where := lc_where||' AND V.OPERATION NOT LIKE ''10%''';
     17    End If;
     18    If gv_flag3 = 'N' Then
     19       lc_where := lc_where||' AND V.OPERATION NOT LIKE ''07%''';
     20    End If;
     21    lc_query := lc_query||lc_where;
     22    dbms_output.put_line(lc_query);
     23    dbms_output.put_line('-----------');
     24    execute immediate lc_query into v_qty;
     25    dbms_output.put_line('Count: '||v_qty);
     26* End;
    SQL> /
    select count(*) from test v  where 1 = 1  AND V.OWNER = 'TEST'
    -----------
    Count: 3
    
    PL/SQL procedure successfully completed.
    
  • Condition within a where condition clause

    Dear friends,
    I am a beginner in PL/SQL and I need your help.
    I'll show you my code (it does not):
    declare
        var_mese VARCHAR2 (2);
    begin
        select max(to_number(MESE)) 
        into var_mese
        from NOC_MONITORAGGIO;
           SELECT count(*)
            FROM noc_sdoc_work a,
                 noc_sdoc b,
                 NOC_MONITORAGGIO
           WHERE NVL(a.CD_STRUTTURA,'x') = NVL(b.CD_STRUTTURA,'x')
             AND NVL(a.CD_SUB_STRUTTURA,'x') = NVL(b.CD_SUB_STRUTTURA,'x')
             AND NVL(a.NR_PRATICA,'x') = NVL(b.NR_PRATICA,'x')
             AND NVL(a.ASL,'x') = NVL(b.ASL,'x')
             AND b.STATO IN ( 1, 2 )         
            and
                if  var_mese in ('03','04','05','06','07','08','09','10','11','12') then
                    NOC_MONITORAGGIO.ANNO_GESTIONE = b.ANNO;
                else
                    NOC_MONITORAGGIO.ANNO_GESTIONE = to_number(b.ANNO)-1;
                end if;
    end;
    My problem is here:
            and
                if  var_mese in ('03','04','05','06','07','08','09','10','11','12') then
                    NOC_MONITORAGGIO.ANNO_GESTIONE = b.ANNO;
                else
                    NOC_MONITORAGGIO.ANNO_GESTIONE = to_number(b.ANNO)-1;
                end if;
    I need a nested where condition

    Thank you
    Leo

    You can code box that using a statement in the WHERE clause:

     and NOC_MONITORAGGIO.ANNO_GESTIONE =
                case
                   when var_mese in ('03','04','05','06','07','08','09','10','11','12') then b.ANNO
                   else to_number(b.ANNO)-1
                end
    
  • WHERE conditional clause with CASE statement

    Hi experts,

    I have a table:

    CREATE THE TABLE HR. TABLE_Y

    (

    NUMBER (2),

    ID NUMBER (2),

    NUMBER (5) CALC

    )

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (1, 1, 10);

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (1, 2, 15);

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (1, 3, 17);

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (1, 4, 20);

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (2, 2, 11);

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (1, 2, 14);

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (2, 3, 18);

    Insert into human resources. TABLE_Y

    (TYPE, ID, CALC)

    Values

    (3, 1, 30);

    COMMIT;

    SQL > SELECT * FROM TABLE_Y ORDER BY 1.2;

    TYPE ID CALC

    ---------- ---------- ----------

    1          1         10

    1          2         15

    1          3         17

    1          4         20

    2          1         14

    2          2         11

    2          3         18

    3          1         30

    I have the query as below,

    I pass a TYPE and an IDENTITY value as a condition for a query.

    SELECT THE TYPE, ID, CALC

    OF TABLE_Y

    WHERE TYPE =: TYPE

    AND IN THE CASE OF IDENTITY

    WHEN: TYPE = 1

    THEN 2

    WHEN: TYPE = 2

    THEN 1

    End

    ;

    When passing a TYPE = 1

    Output

    ID of TYPE CALC

    ----------     ----------   ----------

    1                2           15

    When passing a TYPE = 2

    Output

    ID of TYPE CALC

    ----------    ----------      ----------

    2               1               14

    I want to move a TYPE and ID more values as a condition for a query.

    I'm trying

    SELECT THE VALUE TYPE, ID,

    OF TABLE_Y

    WHERE TYPE =: TYPE

    AND IN THE CASE OF IDENTITY

    WHEN: TYPE = 1

    THEN (1,3)

    WHEN: TYPE = 2

    THEN (1,2)

    End

    ;

    But gives me error:

    ORA-00907: lack of right parenthesis

    During the passage of a desired output TYPE, = 1

    TYPE ID CALC

    ----------  ----------    ----------

    1            1            10

    1            3            17

    During the passage of a desired output TYPE, = 2

    TYPE ID CALC

    ---------- ----------      ----------

    2           1              14

    2           2              11

    Thanks in advance

    BANNER

    ----------------------------------------------------------------

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - production

    PL/SQL Release 10.2.0.4.0 - Production

    CORE 10.2.0.4.0;     Production

    AMT for Solaris: release 10.2.0.4.0 - Production

    NLSRTL Version 10.2.0.4.0 - Production

    Hello

    Here's one way:

    SELECT the type, id, value

    OF table_Y

    WHERE type =: type

    AND ((: type = 1))

    AND id IN (1, 3)

    )

    OR (: type = 2)

    AND id IN (1, 2)

    )

    )

    ;

  • Where conditional Clause based on the length of the field

    Hello people,
    I tried to search for this scenario in OTN and not been able to find any success so I will post the question here.

    I have two tables - with the detail records and the other being a table of codes. I need to join these two tables based on the code and the length of the code. Let me explain using examples.

    Scripts for creating the table and inserts
    create table ILLNESS_CODES(illness_code varchar2(4), illness_description varchar2(100));
    create table PATIENT_TB(patient_id varchar2(4), primary_cause varchar2(4));
    
    insert into illness_codes values('B10', 'Flu');
    insert into illness_codes values('B30', 'Hepatitis');
    insert into illness_codes values('B301', 'Hepatitis A');
    insert into illness_codes values('B302', 'Hepatitis B');
    insert into illness_codes values('B303', 'Hepatitis C');
    
    insert into patient_tb values ('1001', 'B101');
    insert into patient_tb values ('1002', 'B102');
    insert into patient_tb values ('1003', 'B30');
    insert into patient_tb values ('1004', 'B301');
    insert into patient_tb values ('1005', 'B302');
    insert into patient_tb values ('1006', 'B302');
    insert into patient_tb values ('1007', 'B303');
    insert into patient_tb values ('1008', 'B30');
    As you can see that patients * 1001 * and * 1002 * have no codes in the Master table. In this case, I want only the first 3 characters of the ILLNESS_CODES table.
    However, for B30, it has a Code and the same for B301, B302 B303 where I would meet the description based on the exact code.

    Example of output
    Patient ID   Illness Description
    =====================================
    1001         Flu
    1002         Flu
    1003         Hepatitis
    1004         Hepatitis A
    1005         Hepatitis B
    1006         Hepatitis B
    1007         Hepatitis C
    1008         Hepatitis
    Thanks in advance!
    SELECT p.*,
           NVL ( (SELECT illness_description
                    FROM ILLNESS_CODES I
                   WHERE i.illness_code = p.primary_cause),
                (SELECT illness_description
                   FROM ILLNESS_CODES I
                  WHERE i.illness_code = SUBSTR (p.primary_cause, 1, 3)))
      FROM PATIENT_TB p;
    
  • How to add a where condition to seeds VO

    Hi I have a VO PoRequisitionLinesVO.Now knowledge I want to add the SQL where condition...

    How can I do this...? There is no addition of all fields... only adding a where condition clause?

    Will I need to extend that VO? If yes then how should I do this?

    Thank you...

    Yes, you must extend the VO.

    To get the procedure you can search the Internet, there is a great article (that I mentioned below):

    https://blogs.Oracle.com/prajkumar/entry/eo_based_vo_extension_in

    Kind regards

    Sandeep M.

  • How to make a sum of text_field or column with where condition?

    Hi all

    In Oracle forms 6i, I created a form in which there are 5 text_Items (with 20 none of the displayed fields) namely ACCOUNT FD DO, AMOUNT, INTEREST RATE, STATUS and INTEREST_YEAR.

    FD ACCOUNT NO.

    AMOUNT

    INTEREST RATE

    STATUS

    INTEREST_YEAR

    47665

    50000

    1. 11.5

    E

    5750

    37463

    60000

    12

    D

    7200

    47651

    100000

    1. 12.5

    D

    12500

    34766

    70000

    11

    E

    7700

    I want to make the sum of the INTEREST_YEAR where status = 'E '.

    I created a TOTAL_INTEREST_YEAR name field in which I want to display the sum.

    How the sum with where condition?

    Thank you.

    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production

    Oracle form Builder 6i.

    Michael,

    When you write the formula for a calculated item, it does not use PL/SQL expressions (to include built-in DECODING) in Forms 6i.  If there was no conditional control over your calculation, you can simply make your article a summary point and perform the summation over column interest_rate .  However, because your calculation depends on the value in the STATUS column, you will need to use a combination of a calculated item and a summary article because you can't use an IF, DECODE or any other PL/SQL statement in the formula for the calculated item.  Therefore, you need to create a function in the knot of program units and call the function in your formula.  I tested it using the following code and it worked correctly.

    First, create the following function in the node of the object browser program units.

    FUNCTION calc_interest RETURN NUMBER IS
         n_ret_val  NUMBER := 0;
     BEGIN
       IF ( :YOUR_BLOCK.STATUS = 'E' ) THEN
           n_ret_val := :YOUR_BLOCK.interest_rate;
       END IF;
       RETURN n_ret_val;
    END calc_interest;
    

    First, you must change the property to BLOCK request all archives = Yes

    Then, open the palette of your calculated item property, and set the following properties:

    1. calculation = Formula

    2 property Forumla = CALC_INTEREST

    3. point data base = No.

    Now create a second item in the table not based on in your block that will display the amount of the interests summarized.  Open the palette property for this element and set the following properties:

    1 Data Type = number

    2 calculation Mode = Summary

    3. function = sum

    4 summarizes point = "name of your element calculated.

    5 base of data point = No.

    6 canvas = "your canvas.

    When you query your block, you should see the sum of all records where STATUS = 'E '.

    It worked for me, in my example form that I created so this should work for you.

    Craig...

  • SQL only: WHERE Condition pulled the correct runtime of the Central "SQL" tab

    I have a requirement that seems like it should be easy to solve in SQL, but me seems to be stuck with blinders and can't see the solution.

    The 'problem' that I'm trying to solve is to get several reporting units to any use of the SQL even in their where clause for certain types of metrics reports. So this is the solution I am proposing that we store the sql in a central table, which, in a simplified form, would have two columns as:

    GroupName Varchar2 (2000)
    SQL_Filter Varchar2 (5000)


    What I want to do conceptual, it's allow the user (even if they're using MS - SQL) to


    WHERE FunctionName (GetSQL_ForGroupName)

    But first of all, I would tell them that this can be done in Oracle sql. However, I can't understand how to achieve this end. From what I've read so far that oracle will not do:

    WHERE (subquery that returns SQL)

    or (in SQL)

    WHERE VariableSubstition

    or

    WHERE FunctionName (GetSQL_ForGroupName)

    It seems that these things in the WHERE clause allows Oracle after only

    FieldName [operator]

    as in

    WHERE price > (subquery)

    or

    WHERE ID IN (Value) Function

    Is it possible to do a subquery (or anything else) that allows me to draw the where clause running SQL - using only SQL? I can do this with a stored procedure, but it is to say it seems to me I had start coding select specific instructions for them or code so that they could enter select statements (or joins etc.). I don't want to write a complete dynamic reporting engine. I want to do is be able to pull the sql running. This ensures that everyone is 1) with the good sql for metrics 2) by using the same sql and 3) the core sql parameters can be stored in one place instead of 3000 definitions of the various reports.

    I must be looking at this the wrong way, I think. The solution does NOT seem to do WHERE (pull in the SQL running)... but I was not able to find a different way of thinking. For example, WITH does not resolve as you immediately the requirement WHERE fieldname [operator] [subquery | function]. I was browsing the internet and looking through all the books SQL on Safari of O'reilly but I have not met a solution. However, I think, this issue of 'centralization of base SQL' must have been resolved several, several times previously. Why can't I find anything on it then?

    Brad

    You might use a pipeline function to return a TABLE object. This function accepts a parameter that contains the name of the Group (although "GetSQL_ForGroupName" is supposed to represent). The query that they deliver will then look something like this:

    SELECT column_list
    FROM   TABLE(table_function('GroupName'))
    WHERE  additional_conditions
    

    In the function, you can create the SELECT statement that channels the rows in the table with WHERE conditions pulled a table for the provided group name.

  • with different same DataBlock where condition

    Hello

    I use forms 6i and 10g db.

    I have a datablock, say product_master, which retrieves columns product_id, product_name and price.

    and I have 2 control blocks (2 tables)

    what I want is based on list in 2 blocks of different control items, I need to retrieve data from the datablock

    say ctrlblk1 has a listitem named 'pdtlst '.
    so in this case where condition to be - WHERE the product_id =: pdtlst

    and in ctrlblk2 have another element of list "edpdtlst."

    where condition will - WHERE the product_id =: edpdtlst

    Is this possible?
    I found a "WHERE Clause" option in the Palette property of the Datablock.But I want to spend the condition based on the ctrlblock

    Pls help

    Hello

    Changing the block where clause with:

    -- numeric column --
     Set_Block_property( 'block_name', DEFAULT_WHERE, 'col1=' || :ctrl.item1 ) ;
    
    -- char column --
     Set_Block_property( 'block_name', DEFAULT_WHERE, 'col1=''' || :ctrl.item1 || '''') ;
    

    François

  • need to sql where condition evaluates to null

    Hello

    I have a branch_master and I am from the following sql querry

    Select * from branch_master where branch_code =: p3_branch_code

    Here, if I give a null value for: p3_branch_code, querry must return all the branch_code and the details. Incase if I give a particular value as "acts".
    It must then return only the rows where the branch_code has value "acts".

    Otherwise, if the value of the condition is null then querry should ignore the condition itself. Any help is appreciated

    your
    Dr.s.Raghu

    The easiest sollution is

    select * from branch_master where branch_code = nvl(:p3_branch_code,branch_code)
    

    but based on your index, you may need to do a SQL function returning a query and dynamically add the where the clause.
    Kofi

  • WHERE condition in a sql statement

    Hello people,

    I have a screen with data grid where one of the columns is STATES_CODES and other VOLUMES one. Grid consists of several lines. I need to create a CUSTOM SEARCH field that will be filtering on this database.

    Unfortunately a customer wants to enter a search string with custom functions: '+' (plus) to include in the selection of the result and "-" (less) to exclude from the selection of the results. For example: "+ IT + -100". Based on this string, I need to return only the States HE and and exclude volumes with a value of 100.

    A tip how to build a query where condition, so it will be more effective as possible?

    Simple example:

    test data:

    with t (select 'IT' State, volume 90 of any union double

    Select 'IT' State, 100 volumes of all the double union

    Select 'IT' State, 100 volumes of all the double union

    Select 'OF' State, 90 volume of all the double union

    Select 'OF' State, in 100 volumes of all the double union

    Select 'OF' State, in 100 volumes of all the double union

    Select 'NL' State, 90 volume of all the double union

    Select 'NL' State, 100 volumes of all the double union

    Select 'NL' State, 100 volumes of all the double union

    Select 'FR' State, 90 volume of all the double union

    Select 'FR' State, in 100 volumes of all the double union

    Select 'FR' State, in 100 volumes of all the double union

    Select 'ARE' State, 90 volume of all the double union

    Select 'ARE' State, in 100 volumes of all the double union

    Select 'ARE' State, 100 volumes of double

    )

    Select * from t

    Search string: "+ IT + - 100".

    I thought to somehow using regular expressions REGEXP_LIKE condition, but do not know how to change the entered search string in above format as long as the regular expression.

    And if you want to be specific about the characters representing the State and the numbers represent the amount then you will need to divide them into more...

    SQL > with t (select 'IT' State, 90 volume of all the double union)
    2 Select 'IT' State, 100 volumes of all the double union
    3 select 'IT' State, 100 volumes of all the double union
    4. Select 'FROM' State, 90 volume of all the double union


    5. Select 'FROM' State, in 100 volumes of all the double union
    6. Select 'FROM' State, in 100 volumes of all the double union
    7 select 'NL' State, 90 volume of all the double union
    8 select 'NL' State, 100 volumes of all the double union
    9 select 'NL' State, 100 volumes of all the double union
    10. Select 'FR' State, 90 volume of all the double union
    11. Select 'FR' State, in 100 volumes of all the double union
    12. Select 'FR' State, in 100 volumes of all the double union
    13. Select 'ARE' State, 90 volume of all the double union
    14 select 'ARE' State, in 100 volumes of all the double union
    15 select 'ARE' State, in 100 volumes of double
    16              )
    17, ch. as (select "+ IT + -100"as the double criterion)
    18, split as (select regexp_substr (trim (', ' regexp_replace (criteria,'([+ -]) ', ', \1')), "[^,] +', 1, level") as a criterion of)
    19 c
    20 connect the regexp_substr (trim (', ' regexp_replace (criteria,'([+ -]) ', ', \1')), "[^,] +', 1, level") is not null
    21                 )
    22, inc_state as (select substr(criteria,2) as a criterion
    23 split
    where the 24 regexp_like(criteria,'^\+[A-Z]+')
    25                     )
    26, inc_vol as (select substr(criteria,2) as a criterion
    27 split
    where the 28 regexp_like(criteria,'^\+[0-9]+')
    29                    )
    30, exc_state as (select substr(criteria,2) as a criterion
    31 split
    where the 32 regexp_like(criteria,'^\-[A-Z]+')
    33                     )
    34, exc_vol as (select substr(criteria,2) as a criterion
    35 split
    where the 36 regexp_like(criteria,'^\-[0-9]+')
    37                    )
    38-
    39 select *.
    40 t
    where the 41 (exists (select 1
    inc_state 42
    43 where inc_state.criteria = t.state
    ((44) or (select count (*) in inc_state) = 0)
    45 and (exists (select 1
    46 by inc_vol
    where the 47 inc_vol.criteria = t.volume
    ((48) or (select count (*) in inc_vol) = 0)
    49 and (not exists (select 1
    50 to exc_state
    where the 51 exc_state.criteria = t.state
    ((52) or (select count (*) in exc_state) = 0)
    53 and (not exists (select 1
    exc_vol 54
    where the 55 exc_vol.criteria = t.volume
    ((56) or (select count (*) in exc_vol) = 0)
    57.

    ST VOLUME
    -- ----------
    HE 90
    90

  • explain query plan uses no unique index with where condition

    Hi all

    I use in the 10.2.0.5 oracle database Enterprise edition 64-bit on 64-bit windows server 2008.

    I'm following this tutorial on my own table

    Guide to understanding Oracle QUERY PLAN - 10 minutes

    my questions are below

    Analyze table LIB_CLASSIFICATIONS compute statistics;
    explain plan for  SELECT class_id  FROM lib_classifications WHERE class_no = '538' ;
    select * from table(dbms_xplan.display);
    

    the result is less than

    Hash value of plan: 3022072076

    -----------------------------------------------------------------------------------------

    | ID | Operation | Name                | Lines | Bytes | Cost (% CPU). Time |

    -----------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |                     |     1.    10.     5 (0) | 00:00:01 |

    |*  1 |  TABLE ACCESS FULL | LIB_CLASSIFICATIONS |     1.    10.     5 (0) | 00:00:01 |

    -----------------------------------------------------------------------------------------

    Information of predicates (identified by the operation identity card):

    ---------------------------------------------------

    1 - filter ("CLASS_NO" = '538')

    DESC LIB_CLASSIFICATIONS

    Name of Type Null

    ----------------- -------- -------------

    CLASS_ID NOT NULL NUMBER (10)

    CLASS_DESC VARCHAR2 (50)

    REMARKS VARCHAR2 (250)

    CLASS_NO VARCHAR2 (20)

    CLASS_TYPE VARCHAR2 (10)

    CREATE_USER VARCHAR2 (10)

    MODIFY_USER VARCHAR2 (10)

    CREATE_DATE DATE

    MODIFY_DATE DATE

    CLASS_CATEGORY_ID VARCHAR2 (10)

    class_id has a primary key.

    now when I remove the condition where the query, the result is lower;

    Analyze table LIB_CLASSIFICATIONS compute statistics;
    explain plan for  SELECT class_id  FROM lib_classifications ;
    select * from table(dbms_xplan.display);
    

    the result is less than

    Hash value of plan: 262704430

    ------------------------------------------------------------------------------------

    | ID | Operation | Name | Lines | Bytes | Cost (% CPU). Time |

    ------------------------------------------------------------------------------------

    |   0 | SELECT STATEMENT |             |  1558.  6232.     2 (0) | 00:00:01 |

    |   1.  FULL RESTRICTED INDEX SCAN FAST | SYS_C005653 |  1558.  6232.     2 (0) | 00:00:01 |

    ------------------------------------------------------------------------------------

    now it's using indexes with INDEX FAST FULL SCAN.

    I need the index using the WHERE condition as well.

    How to do this?

    Thank you.

    you have indexes on the column class_id not on class_no column how u would expect index to use when there is no index on the column class_no

  • analytical, where condition moved to select clause

    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    PL/SQL Release 10.2.0.4.0 - Production
    CORE 10.2.0.4.0 Production
    AMT for Linux: release 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production

    Hello! I run the following code, but I want to set the condition "CONTRACT_DATE BETWEEN' under SELECTION. Unfortunately, I got different results.
    Thank you in advance.
    WITH T
            AS (SELECT 1 CONTRACT_NO,
                       TO_DATE ('1/2/2012', 'DD/MM/YYYY') CONTRACT_DATE,
                       1000 PRICE
                  FROM DUAL
                UNION ALL
                SELECT 1 CONTRACT_NO,
                       TO_DATE ('2/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
                       50 PRICE
                  FROM DUAL
                UNION ALL
                SELECT 1 CONTRACT_NO,
                       TO_DATE ('3/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
                       150 PRICE
                  FROM DUAL
                UNION ALL
                SELECT 2 CONTRACT_NO,
                       TO_DATE ('4/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
                       75 PRICE
                  FROM DUAL
                UNION ALL
                SELECT 2 CONTRACT_NO,
                       TO_DATE ('3/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
                       900 PRICE
                  FROM DUAL)
    SELECT CONTRACT_NO, MAX (PRICE) OVER (PARTITION BY CONTRACT_NO)  MAX_PRICE
      FROM T
     WHERE CONTRACT_DATE BETWEEN TO_DATE ('2/9/2012', 'DD/MM/YYYY')
                             AND TO_DATE ('3/9/2012', 'DD/MM/YYYY')
    
    output: 
    
    1     150
    1     150
    2     900
    What I tried was:
    SELECT CONTRACT_NO,
           CASE
              WHEN CONTRACT_DATE BETWEEN TO_DATE ('2/9/2012', 'DD/MM/YYYY')
                                     AND TO_DATE ('3/9/2012', 'DD/MM/YYYY')
              THEN
                 MAX (PRICE) OVER (PARTITION BY CONTRACT_NO)
           END
              MAX_PRICE
      FROM T
    
    1     
    1     1000
    1     1000
    2     
    2     900
    
    /* Formatted on 1/21/2013 5:39:48 AM (QP5 v5.139.911.3011) */
    WITH T
            AS (SELECT 1 CONTRACT_NO,
                       TO_DATE ('1/2/2012', 'DD/MM/YYYY') CONTRACT_DATE,
                       1000 PRICE
                  FROM DUAL
                UNION ALL
                SELECT 1 CONTRACT_NO,
                       TO_DATE ('2/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
                       50 PRICE
                  FROM DUAL
                UNION ALL
                SELECT 1 CONTRACT_NO,
                       TO_DATE ('3/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
                       150 PRICE
                  FROM DUAL
                UNION ALL
                SELECT 2 CONTRACT_NO,
                       TO_DATE ('4/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
                       75 PRICE
                  FROM DUAL
                UNION ALL
                SELECT 2 CONTRACT_NO,
                       TO_DATE ('3/9/2012', 'DD/MM/YYYY') CONTRACT_DATE,
                       900 PRICE
                  FROM DUAL)
    SELECT CONTRACT_NO,
           MAX (
              CASE
                 WHEN CONTRACT_DATE BETWEEN TO_DATE ('2/9/2012', 'DD/MM/YYYY')
                                        AND TO_DATE ('3/9/2012', 'DD/MM/YYYY')
                 THEN
                    PRICE
              END)
           OVER (PARTITION BY CONTRACT_NO)
              MAX_PRICE
      FROM T
    
    1     150
    1     150
    1     150
    2     900
    2     900

    Or you need exactly what makes your first request, but you are not satisfied with the performance?

    SY.

  • conditional clause

    I have two table as below

    I need to make my clause condition based on a flag value, so if the value of the indicator is 1 then I use table_a table_b else

    create table table_a ( L_num number);
    create table table_b ( L_num number);
    
    
    insert into table_a values (1);
    insert into table_b values (2);
    
    
    i need to make my from clause condition based on a flag value , so if flag value is 1 then i want to use table_a else table_b
    
    
    declare
    
    
    v_flag number;
    L_var number;
    begin
    v_flag :=1;
    
    
    select L_num into L_var from decode(v_flag,1,table_a,table_b);
    
    
    end;
    
    

    I know that the syntax above is not correct, but can anyone suggest a solution for the same thing?

    Thank you

    PS: I don't want to use dynamic sql.

    I want to be in a request to have two queries if-else won't work for me

    So below the solution will not work for me

    If v_flag = 1

    then

    Select from table_a;

    on the other

    Select of table_b.

    Maybe just

    Select *.

    from table_a

    where: flag = 1

    Union of all the

    Select *.

    of table_b

    where: Pavilion! = 1

    Concerning

    Etbin

  • Problem with dynamic setting where the clause OFA

    Hi all

    I have a view object with the following query:

    SELECT rownum LINENUM,

    B.line_id LINE_ID,

    B.INVENTORY_ITEM_ID INVITMID,

    B.QUANTITY_DELIVERED PICKQTY

    MTL_TXN_REQUEST_HEADERS a,.

    MTL_TXN_REQUEST_LINES B

    WHERE A.HEADER_ID = B.HEADER_ID

    AND A.MOVE_ORDER_TYPE = 2

    AND "on" =: 1

    AND B.TO_SUBINVENTORY_CODE = NVL(:4,B.TO_SUBINVENTORY_CODE)

    AND A.request_number = NVL(:5,A.REQUEST_NUMBER)

    UNION ALL

    SELECT rownum LINENUM,

    a.wip_entity_id LINE_ID,

    a.INVENTORY_ITEM_ID INVITMID,

    a.QUANTITY_ISSUED PICKQTY

    WIP_REQUIREMENT_OPERATIONS has

    eam_work_orders_v b

    WHERE a.wip_entity_id = b.wip_entity_id

    AND "on" =: 2

    AND a.ATTRIBUTE2 = NVL(:4,a.ATTRIBUTE2)

    and b.wip_entity_name = NVL(:6,b.wip_entity_name)

    I need to dynamically pass a condition to my where clause that I can manage it by setting two binding settings in the query of vo and can pass it on but the problem is the connection variable contains a string like 1311,13112,14445 that I need to spend for a domain like B.line_id in the first query and b.wip_entity_id in the second query , so when I'm passing the string as a value it works fine, but it gives for value separetd by comma prob.

    so I tried passing dynamic where clause, but there is every time that the execution of the first clause only how can I dynamically pass both queries.

    vo.setWhereClause ("LINE_ID in" + wherclause);

    Please help me

    Thnaks

    Deb

    Hello

    Actually I'm passing the parameter to the basic page popup, so in page popup page and the base, I was using the VO even to run then, probably due to that he was running again for all data, so for the basic page I created a new VO and tried to pass the parameter like when clause for questioning now it runs very well Thank you for all your help

Maybe you are looking for

  • Security tab does not allow me to add a site to the exception page do not forget the password.

    See above. I want that he remember the passwords for most, but not banking.

  • Satellite P100 loses its next update

    Satellite P100 V3.30 Sound BiOS: Conexant HD Audio v 4.8.0 Windows Vista 32 bit Following a Vista Windows Update which contained an update of his Toshiba, all sounds have disappeared from the laptop. I did a system restore to before the update sound,

  • Satellite M60-104... Keyboard problems

    Hi, someone has problems with the answer of this keyboard. In my view, it does not pick up the keys easily and I always correct the missing letters in my typing. Can it be made more sensitive I type for a living, and it does not react fast enough for

  • Energy cuts on Y410

    Teams of expensive, Energy, cut in a position to set the frequency of the processor of the large - car - low if the system has been installed. My question is, if a system does not install energy cut, which set of frequency frequency of the CPU of the

  • Can install ANY Linux on x120e

    Hello, I bought ThinkPad x120e, and my primary operating system is Linux. Now, I have used Linux for 10 years now, and I have not through such a problem until now, even if other people say that they installed Linux on the thing with success.I tried t