Histogram on non-indexed columns

Hi All,
Is there any point in having histogram on non-indexed column? If we use a non-indexed column for filtering data, there will be a full table scan anyway.
Does having histogram in such column make any difference.
I am on v11.2. Are there any differences/advances in this respect in 11g ?
Thanks in advance.

rahulras wrote:
Hi All,
Is there any point in having histogram on non-indexed column? If we use a non-indexed column for filtering data, there will be a full table scan anyway.
Does having histogram in such column make any difference.
I am on v11.2. Are there any differences/advances in this respect in 11g ?
Thanks in advance.Histogram used to correct estimate selectivity(~ cardinality) by CBO if there are indexes or no!.So if there are indexes then after estimating selectivity based on values CBO can be select FULL TABLE SCAN but not INDEX SCAN!.Finally histograms use when your columns data non uniform distributed(actually skewed).

Similar Messages

  • How Context text search index synchronized when updating non index column?

    Hi,
    Please can any one guide me,
    I have update a column in a table which is not indexed in context index.
    After indexing i synchronize still iam not able to see updated column.
    if update index column in table its getting synchronize and i could see the updated columns in contains
    select statement.please give me a solution for this?

    Hi i have a table called customer and Phone relation ship will be customeriid in both tables
    In customer table i indexed comapnyname
    CREATE OR REPLACE PROCEDURE companycontactColumns_Search
    (p_rowid IN ROWID,
    p_clob IN OUT CLOB)
    AS
    M_clob CLOB;
    BEGIN
    FOR c1 IN (SELECT Customeriid,Companyname||' ' AS data
    FROM Customer
    WHERE ROWID = p_rowid) LOOP
    M_clob := M_clob || c1.data;
    FOR c2 IN
    (SELECT ' ' || PHONENUMBER || ' ' || Phonenumber AS data
    FROM Phone
    WHERE parentiid = c1.Customeriid)
    LOOP
    M_clob := M_clob || c2.data;
    END LOOP;
    END LOOP;
    p_clob := M_clob;
    END companycontactColumns_Search;
    Begin
    Ctx_DDL.create_preference('Companycontactsearch2','USER_DATASTORE');
    ctx_DDL.Set_Attribute('companycontactsearch2','Procedure','companycontactColumns_Search');
    end;
    create index customer_text_idx on Customer(companyname)
    indextype is ctxsys.context Parameters('datastore companycontactsearch2 Sync (on commit)');
    Hi if i update phonenumber in phone table its not getting refereshed please guide me.

  • One can create an index on a non-existent column in a table

    I am using Oracle 10.2.0.3 on Windows 2003. I wanted to create an index on columnb of
    Tablea. When I use statement like:
    Create index index1 on tablea (‘columnb’) …
    Oracle created index: index1. However, when I looked tat the column in user_ind_columns it had some weird colculn like SYS_NCxxxx. For sometime, I had
    No idea what was going on. My index was not being used in queries at all. Then it dawned on me that I should not put single quotes around columnb. Once I removed quotes, things worked as expected.
    But why does Oracle allow index on a non-existent column?

    we cannot create the index on nonexistent column of table We can. Its called a function-based index. Here's how we do it.
    Also read Howard's reply, right above yours.
    SQL> desc t
    Name                                      Null?    Type
    OWNER                                     NOT NULL VARCHAR2(30)
    OBJECT_NAME                               NOT NULL VARCHAR2(30)
    SUBOBJECT_NAME                                     VARCHAR2(30)
    OBJECT_ID                                 NOT NULL NUMBER
    DATA_OBJECT_ID                                     NUMBER
    OBJECT_TYPE                                        VARCHAR2(19)
    CREATED                                   NOT NULL DATE
    LAST_DDL_TIME                             NOT NULL DATE
    TIMESTAMP                                          VARCHAR2(19)
    STATUS                                             VARCHAR2(7)
    TEMPORARY                                          VARCHAR2(1)
    GENERATED                                          VARCHAR2(1)
    SECONDARY                                          VARCHAR2(1)
    SQL> create index t_idx on t( substr(object_name, 1, 5));
    Index created.
    SQL> select column_name from user_ind_columns where index_name = 'T_IDX';
    COLUMN_NAME
    SYS_NC00014$
    SQL> select index_type from user_indexes where index_name = 'T_IDX';
    INDEX_TYPE
    FUNCTION-BASED NORMAL
    SQL>

  • Gather_table_stats with a method opt of "for all indexed columns size 0"

    I have 9 databases I support that contain the same structure, and very similar data concentrations. We are seeing inconsistent performance in the different databases due to bind variable peeking.. I have tracked it down to the Min and Max values that are gathered during the analyze. I analyze from one cluster, and export/import those statistics into the other clusters.. I then go about locking down the stats gathered. Some of the statistics are on tables that contain transient data (the older data is purged, and new data gets a new PK sequence number).
    Since I am gathering statistics with a 'FOR ALL INDEXED COLUMNS SIZE 1', a min and max value are grabbed. This value is only appropriate for a short period of time, and only for a specific database. I do want oracle to know the density to help calculate, but I don't want cardinality based on whether the current bind values fall in this range..
    Example
    COLUMN PK
    When I analyze the min is 1 and max is 5. I then let the database run, and the new min is 100 and max is 105.. same number of rows, but different min/max. At first a select * from table where pk>=1 and pk <=5 would return a cardinality of 5.. Later, a seelct * from tables where pk>=100 and pk<=105 would return a cardinaility 1.
    Any ideas how to avoid this other than trying set min and max to something myself (like min =1 max = 99999999). ??

    MarkDPowell wrote:
    The Oracle documentation on bind variable peeking said it did not peek without histograms and I cannot remember ever seeing on 9.2 where the trace showed otherwise. Mark,
    see this simple test case run on 9.2.0.8. No histograms, but bind variable peeking, as you can see that the EXPLAIN PLAN output generated by AUTOTRACE differs from the estimated cardinality of the actual plan used at runtime.
    Which documentation do you refer to?
    SQL>
    SQL> alter session set nls_language = 'AMERICAN';
    Session altered.
    SQL>
    SQL> drop table bind_peek_test;
    Table dropped.
    SQL>
    SQL> create table bind_peek_test
      2  as
      3  select
      4             100 as n1
      5           , cast(dbms_random.string('a', 20) as varchar2(20)) as filler
      6  from
      7             dual
      8  connect by
      9             level <= 1000;
    Table created.
    SQL>
    SQL> exec dbms_stats.gather_table_stats(null, 'bind_peek_test', method_opt=>'FOR ALL COLUMNS SIZE 1')
    PL/SQL procedure successfully completed.
    SQL>
    SQL> variable n number
    SQL>
    SQL> variable n2 number
    SQL>
    SQL> alter system flush shared_pool;
    System altered.
    SQL>
    SQL> exec :n := 1; :n2 := 50;
    PL/SQL procedure successfully completed.
    SQL>
    SQL> set autotrace traceonly
    SQL>
    SQL> select * from bind_peek_test where n1 >= :n and n1 <= :n2;
    no rows selected
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1000 Bytes=24
              000)
       1    0   FILTER
       2    1     TABLE ACCESS (FULL) OF 'BIND_PEEK_TEST' (Cost=2 Card=100
              0 Bytes=24000)
    Statistics
            236  recursive calls
              0  db block gets
             35  consistent gets
              0  physical reads
              0  redo size
            299  bytes sent via SQL*Net to client
            372  bytes received via SQL*Net from client
              1  SQL*Net roundtrips to/from client
              4  sorts (memory)
              0  sorts (disk)
              0  rows processed
    SQL>
    SQL> set autotrace off
    SQL>
    SQL> select
      2             cardinality
      3  from
      4             v$sql_plan
      5  where
      6             cardinality is not null
      7  and      hash_value in (
      8    select
      9            hash_value
    10    from
    11            v$sql
    12    where
    13            sql_text like 'select * from bind_peek_test%'
    14    );
    CARDINALITY
              1
    SQL>
    SQL> alter system flush shared_pool;
    System altered.
    SQL>
    SQL> exec :n := 100; :n2 := 100;
    PL/SQL procedure successfully completed.
    SQL>
    SQL> set autotrace traceonly
    SQL>
    SQL> select * from bind_peek_test where n1 >= :n and n1 <= :n2;
    1000 rows selected.
    Execution Plan
       0      SELECT STATEMENT Optimizer=CHOOSE (Cost=2 Card=1000 Bytes=24
              000)
       1    0   FILTER
       2    1     TABLE ACCESS (FULL) OF 'BIND_PEEK_TEST' (Cost=2 Card=100
              0 Bytes=24000)
    Statistics
            236  recursive calls
              0  db block gets
            102  consistent gets
              0  physical reads
              0  redo size
          34435  bytes sent via SQL*Net to client
           1109  bytes received via SQL*Net from client
             68  SQL*Net roundtrips to/from client
              4  sorts (memory)
              0  sorts (disk)
           1000  rows processed
    SQL>
    SQL> set autotrace off
    SQL>
    SQL> select
      2             cardinality
      3  from
      4             v$sql_plan
      5  where
      6             cardinality is not null
      7  and      hash_value = (
      8    select
      9            hash_value
    10    from
    11            v$sql
    12    where
    13            sql_text like 'select * from bind_peek_test%'
    14    );
    CARDINALITY
           1000
    SQL>
    SQL> spool offRegards,
    Randolf
    Oracle related stuff blog:
    http://oracle-randolf.blogspot.com/
    SQLTools++ for Oracle (Open source Oracle GUI for Windows):
    http://www.sqltools-plusplus.org:7676/
    http://sourceforge.net/projects/sqlt-pp/

  • What value for DBMS_STATS method_opt= 'for all indexed columns ???'

    What value, one should use for method_opt , while collecting stats for database/schema/table.
    It is obseverd AUTO never give good result, in some case "for all indexed columns 1" work fine and some case "for all indexed columns 254".
    Please advise , what is right way to collect stats.
    OS : Linux AS 4
    DB : 9.2.0.8 , 10.2.0.3
    Thanks

    Gather AUTO. Gathers all necessary statistics automatically. Oracle implicitly determines which objects need new statistics, and determines how to gather those statistics. When GATHER AUTO is specified, the only additional valid parameters are stattab, statid, objlist and statown; all other parameter settings are ignored. Returns a list of processed objects.
    If you specify the for all indexed columns, or specify the column, it will gather histograms. Those are useful if you have an uneven data distribution, and are specially useful for DSS databases, where Oracle will determine if a column is suitable, on a given data rage, to perform full table scan or index scan. If uncertain about it I suggest you not to gather column statistics, as they are costly.
    ~ Madrid.

  • Order of indexed columns in the index

    Hi Gurus,
    I have a small problem in front of me and I wud like to take some inputs
    from you Gurus.Here is question
    1. Is order of the index is important in CBO?
    say
    1.I have a concatenated index on col1,col2
    2.In the sql statement's used in my project I have statements "where
    col1=1 and col2 = 1" as well as
    "where col2=1 and col1=1" and my opinion is that CBO will use the Index
    in both the scenarios( I have cheked RBO for the same and RBO is able to
    use the index) whereas some senior persons out here are telling
    otherwise..... that it will not use the index for "where col2=1 and
    Col1=1)
    pls clarify
    Cheers
    Sriram Kumar

    When I attended an Oracle 8i SQL Statement Tuning Workshop, I believe I understood things as in the response above. However, the class was applicable to Oracle 8.1.5 and I am now using Oracle 8.1.7, so some things may have changed. I have included a test of various scenarios below. I would have expected all except the last one to use the index, because col2 is not the leading edge of the composite index on col1, col2. Much to my surprise it also used the index there.
    SQL> CREATE TABLE test_table AS
      2  SELECT empno col1, mgr col2 FROM emp
      3  /
    Table created.
    SQL> UPDATE test_table
      2  SET    col1 = 1, col2 = 1
      3  WHERE  col1 = 7782
      4  AND    col2 = 7839
      5  /
    1 row updated.
    SQL> CREATE INDEX test_idx
      2  ON test_table (col1, col2)
      3  /
    Index created.
    SQL> ANALYZE TABLE test_table
      2  COMPUTE STATISTICS
      3  FOR TABLE
      4  FOR ALL INDEXES
      5  FOR ALL INDEXED COLUMNS
      6  /
    Table analyzed.
    SQL> SET AUTOTRACE ON EXPLAIN
    SQL> SELECT * FROM test_table
      2  WHERE col1 = 1 AND col2 = 1
      3  /
          COL1       COL2                                      
             1          1                                      
    1 row selected.
    Execution Plan
       0                                                       
    SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=6)  
       1    0                                                  
      INDEX (RANGE SCAN) OF 'TEST_IDX' (NON-UNIQUE) (Cost=1 Card
    =1 Bytes=6)                                                
    SQL> SELECT * FROM test_table
      2  WHERE col2 = 1 AND col1 = 1
      3  /
          COL1       COL2                                      
             1          1                                      
    1 row selected.
    Execution Plan
       0                                                       
    SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=6)  
       1    0                                                  
      INDEX (RANGE SCAN) OF 'TEST_IDX' (NON-UNIQUE) (Cost=1 Card
    =1 Bytes=6)                                                
    SQL> SELECT * FROM test_table
      2  WHERE col1 = 1
      3  /
          COL1       COL2                                      
             1          1                                      
    1 row selected.
    Execution Plan
       0                                                       
    SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=6)  
       1    0                                                  
      INDEX (RANGE SCAN) OF 'TEST_IDX' (NON-UNIQUE) (Cost=1 Card
    =1 Bytes=6)                                                
    SQL> SELECT * FROM test_table
      2  WHERE col2 = 1
      3  /
          COL1       COL2                                      
             1          1                                      
    1 row selected.
    Execution Plan
       0                                                       
    SELECT STATEMENT Optimizer=CHOOSE (Cost=1 Card=1 Bytes=6)  
       1    0                                                  
      INDEX (FULL SCAN) OF 'TEST_IDX' (NON-UNIQUE) (Cost=1 Card=
    1 Bytes=6)                                                 

  • Non-indexed queries

    Hello,
    Is there a way to retrieve all the non indexed query's used in the database?
    I use toad to monitor the database and there is a certain amount of queries non-indexed I want to find out.
    TIA.
    Alder

    In TOAD the 'Database -> Spool SQL -> Spool SQL to Screen' option is often your friend.
    From the spool output produced while refreshing the Database Monitor in TOAD you can see that TOAD uses the following query to derive the ratio of non-indexed to indexed SQL.
    SELECT SUM (DECODE (name, 'table scans (long tables)', VALUE, 0)) /
           (SUM (DECODE (name, 'table scans (long tables)', VALUE, 0)) +
            SUM (DECODE (name, 'table scans (short tables)', VALUE, 0))) *
           100
              non_indexed_sql,
           100 -
           SUM (DECODE (name, 'table scans (long tables)', VALUE, 0)) /
           (SUM (DECODE (name, 'table scans (long tables)', VALUE, 0)) +
            SUM (DECODE (name, 'table scans (short tables)', VALUE, 0))) *
           100
              indexed_sql
    FROM   v$sysstat
    WHERE  1 = 1
    AND    (name IN ('table scans (long tables)', 'table scans (short tables)'));As you can see this is simply the ratio of the count of 'table scans (long tables)' against 'table scans (short tables)' which are simple metrics for the database held in v$sysstat. This cannot be traced to the original statements themselves.
    You could try looking at the operation/options columns in v$sql_plan or dba_hist_sql_plan views - BUT - as has already been pointed out, it is not always preferable to use indexes over other access paths to answer queries - it is heavily dependent on the data distribution and the question being asked. You would be better off looking at which queries were resource intensive.

  • ORDER BY ON INDEX COLUMN IS TAKING MORE TIME

    Hi,
    The following SQL query when executed with ORDER BY is taking 3 mins. If we remove ORDER BY it is taking 32 secs. We have an index on ID which is used in ORDER BY clause. Can any one tell us what could be wrong? My assumption is ORDER BY on an index column should not take that much of time. Is there any configuration that we need to make or missing?
    We are on 11g R2.
    Query is
    SELECT * FROM (SELECT /*+ FIRST_ROWS */ a.*, ROWNUM rnum  FROM
    (SELECT DISTINCT ENTITYID AS a1, ENTITYCLASS AS a2, STARTDATE AS a3, ENDDATE AS a4, EXTERNALOBJECTID AS a5, LASTMODIFIEDUSER AS a6, ID AS a7, PARTITION AS a8,    DESCRIPTION AS a9, NAME AS a10, PERMISSIONS AS a11, CREATEDDATE AS a12, ACTIVITY AS a13, ENTITYVERSION AS a14, EXTERNALNAME AS a15, NOSPEC AS a16,
    ADMINSTATE AS a17, OWNER AS a18, LASTMODIFIEDDATE AS a19, EXTERNALARRANGEMENT AS a20, OBJECTSTATE AS a21, EXTERNALMANAGEMENTDOMAIN AS a22,
    CREATEDUSER AS a23, SPECIFICATION AS a24 FROM Service WHERE (ENTITYCLASS = 'SERVICEDAO') ORDER BY ID ASC)
    a WHERE ROWNUM <= 25) WHERE rnum > 0Here is the explain plan link
    https://stbeehive.oracle.com/content/dav/st/Rama%20%20Public%20Workspace/Public%20Documents/explainplan_13339959.JPG
    https://stbeehive.oracle.com/content/dav/st/Rama%20%20Public%20Workspace/Public%20Documents/explainplandetailed_13339959.JPG
    Thanks,
    Rama
    Edited by: user9954330 on Nov 8, 2011 1:16 AM

    user9954330 wrote:
    We replaced the hint with ALL_ROWS. With this change , we observed the query performed worse. Any other pointers? I will provide the other details as given in the template shortly.
    Thanks,
    RamaThread: HOW TO: Post a SQL statement tuning request - template posting
    HOW TO: Post a SQL statement tuning request - template posting

  • Issue with non calculated column in a fact table

    Hi All,
    With 3 facts(Fact1,Fact2,Fact3) and 2 Confirmed Dimensions my joins work fine in Criteria when I include All calculated columns from facts. If I try to include a non calculated column from Fact1(Which is a number Data type) Columns from Fact2 and Fact3 show Null values. I know it is not recommended to include dimension columns in fact , does OBIEE not support Number type non calculated columns as well? Is there any work around that I can bring in my non calculated column from Fact and still get results for other fact columns.Iam at 11.1.1.7 of OBIEE
    Let me know if Iam not clear.
    Your help is much Appreciated.
    Thanks,
    Vineela.

    i would like to add 2 fields into my fact tables - LOAD ID (populated by a sequence during each load) and LOAD DATE.
    as these fields are not related to any reporting dimensions, it is still possible to add them in OWB ? the fact wizard always ask for a foreign key to a dimension ...
    Duncan,
    If you want to add non dimensional attributes to a fact by using OWB, you can create additional measures to it and use them as attributes.
    Igor

  • Why oracle text index column taking long  time

    why oracle text index column is taking long time to return result.I created text index on a column if I run the query on a single table result is very fast.If I join table with other table (10 records only )
    it is taking long time but in explain plan it is searching by index only.
    I created this index for searching a varchar2 column,the data is comma seperated values like ( UK,US,IT,BR) and the table having records 20 lakhs.Normally if I query with like operater
    ( like '%US%' ) it is taking full table scan because I am using '%' both sides. Please help me on this regard how to search the data with less time. Here is may sample code and explain plan.
    SQL*Plus: Release 9.2.0.1.0 - Production on Wed Jan 28 16:54:22 2009
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Connected to:
    Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
    With the Partitioning, OLAP and Oracle Data Mining options
    JServer Release 9.2.0.1.0 - Production
    SQL&gt; set timing on
    SQL&gt; set linesize 180
    SQL&gt; explain plan for SELECT T.esongid FROM (SELECT A.ESONGID FROM wcmedeco.EDECO_ESONGS_TERR_CTRY 
    A WHERE CONTAINS(A.TERR_CTRY_NAMES,'US')&gt;0  
      2  GROUP BY A.ESONGID)K,T
      3  WHERE  K.ESONGID=T.ESONGID;
    Explained.
    Elapsed: 00:00:00.01
    SQL&gt; select *from table(dbms_xplan.display);
    PLAN_TABLE_OUTPUT
    | Id  | Operation                      |  Name                   | Rows  | Bytes | Cost  |
    |   0 | SELECT STATEMENT               |                         |     1 |    26 |     4 |
    |   1 |  NESTED LOOPS                  |                         |     1 |    26 |     4 |
    |   2 |   VIEW                         |                         |     1 |    13 |     4 |
    |   3 |    SORT GROUP BY               |                         |     1 |    89 |     4 |
    |   4 |     TABLE ACCESS BY INDEX ROWID| EDECO_ESONGS_TERR_CTRY  |     1 |    89 |     2 |
    |   5 |      DOMAIN INDEX              | IDX_TERR_CTRY_NAMES     |       |       |     0 |
    |   6 |   INDEX RANGE SCAN             | IDX_ESONGID_T           |     1 |    13 |     1 |
    PLAN_TABLE_OUTPUT
    Note: cpu costing is off, 'PLAN_TABLE' is old version
    14 rows selected.
    Elapsed: 00:00:00.00
    SQL&gt; Regards,
    Rajasekhar

    You have not formatted your code properly so we cannot see the query you're executing. Please put some line breaks in.
    Secondly, how fresh are the statistics on those tables? Are you really returning one record out of twenty million?
    Cheers, APC
    blog: http://radiofreetooting.blogspot.com

  • Filter Data with Merged and non merged columns in one

    Hi there,
    I have an excel spreadsheet that has got merged and non merged columns. What I want to be able to do is, filter a row that has got merged column and non merged columns. But when I filter it only takes the first line, rather than the merged and non merged
    columns.
    With this data I have one merged column which spans 6 rows, and then in the same row I have 6 rows with different points in, and what I want to do is filter my list, but be able to see the merged coloum aswell as the 6 points.
    Any ideas are much appriciated.
    Cheers
    SAN

    You cannot filter across a row - so I have assumed that what you mean is that some cells in columns are merged to serve as the headers, and the data is in the came columns but in the row(s) below the header. If this is incorrect, ignore this post.
    For this example, I have assumed E to J are the column of data and merged cells, column K is free, and the first merged header is in row 1:
    In K1, enter
    =E1
    in K2, enter
    =IF(COUNTA(E2:J2)=1,E2,K1)
    and copy down. Then filter based on column K, and it will show the headers and the data for the selected header value.
    HTH, Bernie

  • Region sql query(updateable report) data entry in non db columns

    In a tabular report type updateable report
    What is the best way to provide data entry into a non db column a) (to accept parameters for some on demand pl/sql processes)?
    Only when setting a) as a standard report column the db insert/update transaction can be processed
    When changing a) to text field the db insert/update transaction fails with en error (screen/db are not in sync which is not actually the case)
    a) should not be part of the db insert/update transactions but still allow data entry
    How can this be achieved?
    Thanks
    Peter

    Hi Peter,
    I think the easiest solution is to use an updateable view instead of the direct table access.
    Here is an example:
    CREATE OR REPLACE VIEW V_EMPLOYEES
    AS
    SELECT EMPLOYEE_ID
         , FIRST_NAME
         , LAST_NAME
         , FIRST_NAME||' '||LAST_NAME AS FULL_NAME
      FROM EMPLOYEES
    CREATE OR REPLACE TRIGGER TRG_V_EMPLOYEES
        INSTEAD OF INSERT OR UPDATE OR DELETE
        ON V_EMPLOYEES
        REFERENCING NEW AS new OLD AS old
        FOR EACH ROW
    BEGIN
        IF UPDATING
        THEN
            UPDATE EMPLOYEES
               SET FIRST_NAME = :new.FIRST_NAME
                 , LAST_NAME  = :new.LAST_NAME
             WHERE EMPLOYEE_ID = :old.EMPLOYEE_ID
        -- insert and delete is not allowed
        ELSIF INSERTING
        THEN
            NULL; -- there would be a insert code
        ELSIF DELETING
        THEN
            NULL; -- there would be the delete code
        END IF;
    END;
    /FIRST_NAME||' '||LAST_NAME AS FULL_NAME in the example view simulates your function call.
    There might be a possibility to do it in APEX as well, but that was the first solution which came into my mind.
    Patrick
    Check out my APEX-blog: http://inside-apex.blogspot.com
    Check out the ApexLib Framework: http://apexlib.sourceforge.net

  • Displaying a non existent column from a Table.

    Hi
    I have an SQL Query that returns back a count of all the
    entities
    select count(*)'COUNTER',
    id_entity 'ENTITY'
    from  claim 
    where id_status = 'O'
    group by id_status,id_entity 
    order by id_entity ASC
    Output
    COUNTER ENTITY
    169     AGL
    6       DBC
    28      DELI would like to put a non existent column called 'Type' with a counter
    of 0,so that the output looks like :
    COUNTER ENTITY
    0       TYP
    169     AGL
    6       DBC
    28      DELIs this possible ? What do I need to change in my select clause
    for this?
    Please help

    monalalwani, do you mean something like this?
    you have -
    1 select count(*) as counter, deptno
    2 from emp
    3* group by deptno
    UT1 > /
    COUNTER DEPTNO
    5 10
    5 20
    6 30
    -- but want counter = 0 for dept 0
    UT1 > select count(*) as counter, deptno
    2 from emp
    3 group by deptno
    4 union
    5 select 0, 00
    6 from dual
    7 /
    COUNTER DEPTNO
    0 0
    5 10
    5 20
    6 30
    HTH -- Mark D Powell --

  • Order By Clause on Non-Database Column using Forms

    How to Sort by using Order by Clause on Non-Database Column using Forms6i

    Eugene,
    What is the error message/ number you are seeing? If you run "select name from tblperson order by name" do you still get an error?

  • Select non-zero columns

    if we have data in the following format:
    c1 c2 c3 c4
    0 234 0 12
    0 111 0 11
    0 280 0 38
    0 387 0 49
    the above no.of columns can be variable
    how can we select only non-zero columns - c2 and c4

    Hi,
    This requires dynamic SQL.
    To find if table_x.c1 contains anything except 0 (incluiding NULL), you could say:
    SELECT  'TABLE_X', 'COL1'  FROM  dual  WHERE EXISTS (SELECT NULL FROM table_x WHERE NVL (c1, 1) != 0);What you have to do, using dynamic SQL, is write a SELECT statement like that for every column you want to test.
    So you'll need a query like
    SELECT  'SELECT '''
            || table_name
            || ''', '''
            || column_name
            || ''' FROM dual WHERE EXISTS (SELECT NULL FROM '
            || table_name
            || ' WHERE NVL ('
            || column_name
            || ', 1) != 0);'  -- Omit ';' in PL/SQL
    FROM    all_tab_cols
    WHERE   ...  -- whatever you needIn SQL*Plus, you can write all of these statements to a SPOOL file, and then execute it by saying @spool_file.
    In PL/SQL, you would use EXECUTE IMMEDIATE to run each statement.

Maybe you are looking for

  • Why is default scan in Adobe Acrobat 9.3.1 legal size

    I have HP LaserJet with new software. I scan directly from Adobe Acrobat 9.3.1 (Windows 7, 64 bit). The only scanner I can find in dropdown is WIA. I do not see the twain driver - even though I can scan with twain driver in the HP scanning applicatio

  • Using Flex Component Kit for FlashCS3 in Flash Builder

    Hi at all, i apologize for my english. I'm using Flash Builder 4 and i've created a movie clip symbol in Flash CS4. I convert the flash symbol in Flex Component but Flash Builder sends a "Verify Error" because the mx.flash.UIMovieClip class in the Fl

  • Upgrading iMac 2007 (7,1)  Memory

    I seem to find my trusty iMac a bit sluggish and want to upgrade the RAM (that and i was given a copy of Windows 7 as a gift) so 1 gig isnt enough to run two modern OS's. I've been doing a lot of research (making sure i know what i'm doing and making

  • How to create a z-table to maintain RFC destinations??

    Dear Experts, Can you please guide me to create a Z table where I can maintain RFC destinations?? Regards, Mamai.

  • FB Debug application loaded with SWFLoader

    I am fairly new to flex builder, I am working on a fairly large project that has many pages. To reduce the application sizes, I have created seperate applications for each type of user. The login page then loads the appropiate application useing SWFL