What is the meaning of the statistical Tables?

Hello
I try to use the DBMS_STATS to collect statistics.
I did the following:

BEGIN
DBMS_STATS.create_stat_table (ownname = > 'MYOWNER', stattab = > 'STAT_TAB');
DBMS_STATS.gather_table_stats (ownname = > 'MYOWNER', tabname = > "MYTABLE", stattab = > 'STAT_TAB');
END;
*/*

and when I look at the STAT_TAB table I find that it's been created with this description:

SQL > desc STAT_TAB
Name                                      Null?    Type
----------------------------------------- -------- ----------------------------
STATID VARCHAR2 (30)
TYPE                                               CHAR(1)
VERSION NUMBER
FLAGS                                              NUMBER
C1                                                 VARCHAR2(30)
C2                                                 VARCHAR2(30)
C3                                                 VARCHAR2(30)
C4                                                 VARCHAR2(30)
C5                                                 VARCHAR2(30)
N1                                                 NUMBER
N2                                                 NUMBER
N3                                                 NUMBER
N4                                                 NUMBER
N5                                                 NUMBER
N6                                                 NUMBER
N7                                                 NUMBER
N8                                                 NUMBER
N9                                                 NUMBER
N10                                                NUMBER
N11                                                NUMBER
N12                                                NUMBER
D1                                                 DATE
R1                                                 RAW(32)
R2                                                 RAW(32)
CH1 VARCHAR2 (1000)

How I can undestand the meaning of the columns? I can't get the meaning of the names that oracle did by default, I guess. My version is Oracle 8.1.7.
Thank you

Check here:
[http://skdba.blogspot.com/2006/06/keeping-history-of-cbo-stats.html]

-André

Tags: Database

Similar Questions

  • What are the operating tables

    Hi all

    What are the operating tables in EBS
    How to find the names of tables of them?

    Thanks for the reply

    PLX view this link

    My requirement is almost the same here
    but not sure on my transaction table
    Can u please help me?

    How can I insert new values in the Tables of the Transaction

  • Does anyone know what are the MDXT tables?

    Hi people,

    It is a bit of a puzzle game (does not seem to interest a SR).  My production environment of 11 GR 2 moves to a virtual configuration (which probably is indifferent to the question).  On these new servers, I noticed that Oracle Spatial index is based are intermittently leaving behind him a second series of paintings of domain with the MDXT_ prefix which seem to do with MBR statistics.  These paintings sometimes seems to fall with the index and sometimes not, so leave things a little messy.  They cause no problems and spatial indexes appear to be well.  It's just a curiosity that I've not met before.

    Someone else has encountered this and find out why this happens on one system and not another?

    Thank you

    Paul

    I'm a few months late replying to this topic... but this morning I read this post: How to check its spatial index stats together?

    And it made me realize that I have have seen loads of tables MDXT these last few months and I was wondering what they are - so I came across this thread.

    The 12 c documentation says: https://docs.oracle.com/database/121/SPATL/sdo_index_query.htm#SPATL1520

    "The Oracle database optimizer collects statistics that describe the details on the database and its objects. Statistics are critical to the ability of the optimizer to choose the best course of execution of a SQL statement.

    In order to use such procedures as DBMS_STATS. GATHER_INDEX_STATS and DBMS_STATS. GATHER_SCHEMA_STATS to collect statistics of indexes associated with a spatial index, the CREATE TABLE privilege must benefit all users of the database who will perform the collection of statistics.

    If the statistics are collected with success, a table with the name in the form MDXT_ % objID will be created for each index whose statistics are collected. Each table of this type will be filled with spatial statistical data, 512 default lines. »

    OK, now it makes sense.  I presume that the new statistics collection algorithms have been backported in 11.2.0.4.

    > These paintings sometimes seems to fall with the index and sometimes not, so leave things a little messy

    It sounds like the bug 17984331: ORPHANS TABLES ON LOWER VACUUM TABLE WITH SDO_GEOMETRY COLUMN AFTER STATS

    Correction to paragraph 12.2 apparently.

    John

  • What is the groups table?

    Hello

    In the table which are groups of data?

    Best regards

    What do you mean by groups of data? I know two tables that contain groups.

    CR_GROUP contains the ADMIN > Security > workflow management groups

    SU_SUPPORT_GROUP contains the ADMIN > Security > groups IPK

  • What is the best way to move the data from the app and Server data structures?

    Hi guys,.

    I developed my application locally with Apex 4.2 and Oracle 11 g XE on Windows 7. Not far away, it is time to move the application to a server Oracle Apex. I guess that Exim is the way to go app. But what about the APA tables and data (tables/as 'customer' and 'account' created specially for the application)? I've been using a modeling tool, so I can run a DDL script to create the database server data structures. What is the best way to move the application data on the server? Is it possible to move the structures and data in a single process?

    Thank you
    Kim

    There is probably another way to get here, but in Developer SQL, on the navigation tree, expand objects until your table, right-click, and then click EXPORT... you will see all the options. It is a tedious process and it sucks IMO, but yes, it works. This is zero especially because 1) it's a table at a time, 2) If your data model is robust and has constraints and sequences and triggers, then you will need to disable all for the insert and we hope you can re-enable constraints, etc. without hitch (good luck, unless you have only a handful of tables)

    I prefer to use the oracle EXP command-line to export an entire schema, then the server target, I use IMP to import the schema. In this way, it is almost true. This makes the dirty life if you develop multiple applications in a single schema, and I felt pain - however - it is much easier to drop the tables and other objects is to create them! (thus, even if the process of EXP/IMP moved more than you wanted to "move".. blow everything you don't want on the target after the fact...)

    You can use method datapump oracle too.

    If not, what can be done, IF you have access to both servers of your instance of SQL developer (or if you can tnsping both already from the command line, you can use SQL * MORE), is to run a script that will identify the objects of your applications apex (usually by the prefix for the names of objects, such as % EBA_PROJ_ etc.) and do all the manual work for you. I've created a script that does just that so that I can pass data from dev to prod servers on a dblink. It is difficult because of the order that must be executed to disable constraints and then turn it back on and of course, more complicated if don't always precede you ALL your "objects demand '... (tables, views, triggers, sequences, functions, procs, indexes, etc.)

  • the base tables store jobs oem

    Hello

    I have some work in the Oracle Enterprise Manager job console. (These jobs call a PL/SQL procedure). Can you please let me know what are the base tables that store the names of this work, work planning and other information about jobs? The version of database is Oracle 9i and OEM version 9.0.2

    Thank you
    RK

    Hello
    using the repository database

    Work 4SystemJOBS tables
    --> Connect as SYSDBA
    # > export ORACLE_SID = emrep
    # > sqlplus / as sysdba
    SQL # > select table_name from user_tables where table_name like '% % ';

    4Emrep (OEMGC) work tables
    --> Connect as SYSMAN
    # > sqlplus sysman/MYPASS@emrep
    SQL # > select table_name from user_tables where table_name like '% % ';
    SQL # > mgmt_job desc;

    * T

  • What is the preferred means of data transmission as a type of record between the nested table of pl/sql program or an associative array

    What is the preferred means of data transmission in the associative array of the nested table record vs

    Choose between Nested Tables and associative arrays

    The two nested tables and associative arrays (formerly index - by tables) use similar index notation, but they have different characteristics when it comes to persistence and ease of passing parameters.

    Nested tables can be stored in a column of data, but can of associative arrays. Nested tables can simplify the SQL operations where you would normally join a single-column table with a larger table.

    Associative arrays are appropriate for relatively small lookup tables where the collection can be constructed in memory whenever a procedure is called or a package is initialized. They are good for the collection of the information volume is unknown beforehand, because there is no fixed limit on their size. Their index values are more flexible, as associative array indices can be negative, can be no sequential and can use values of string instead of numbers.

    PL/SQL automatically converts between the bays of the host and the associative arrays that use values of digital keys. The most effective way to move the collections to and from the database server is to implement data values in associative arrays, and then use these associative arrays with erections in bulk (the FORALL statement or BULK COLLECT clause).

    With the help of documents and Collections of PL/SQL

    Read this:

    How to pass the record set as a parameter of the procedure.

    https://community.Oracle.com/thread/2375173?TSTART=0

  • What is the physical meaning of automatic indexing of table entry...

    What is the physical interpretation of the automatic indexing. ?

    You wire up a table on the edge of a loop, it sequentially will index the table for you as he travels the loops. A While loop will also do this, but it is much more common on loops For, therefore, loops For making automatically while the While loops must be 'right click' and said to the index in the array. Get it?

  • What is the meaning of the OPA session tables in Siebel for OPA? That is to say why they were created when they should be used? and what was the first thought behind the creation of tables of session?

    Hi all

    I wanted to know best practices regarding the use of the tables of session OPA? that is, what was the initial logic of creating tables of session? where we should use them and why? also can you please argue for and against about two approaches mentioned below

    Method 1: Save and reterieve OPA session data tables using session ID and case ID?

    Approach 2: Save data in Siebel database tables and just use reterieve case Id Siebel data and save the back.

    Thanks for your replies.

    Session tables are there to allow easy storage of the results of an interview of the OPA. It can be used to extract data from an interview, but probably more useful as an archive of past interviews. Is it possible to load a previous interview in the determinations of the Web from this table.

    1. This can be very useful to resume a partially completed interview.

    2. it can be used as verification of de facto mechanism to see what has been entered in an interview.

    In general I prefer to approach 2 where there are intercepted the incoming data to an interview in a before handler registration and then save the data you need from the interview in the location that you must save it.

  • What is the meaning of the optimizer based on CSSTidy referring "A ORDERED USE_NL" Please?

    Hi all

    What is the meaning of the optimizer based on CSSTidy referring "A ORDERED USE_NL" Please?

    I searched the internet without great success (indicators of optimizer). Can you please enlighten me on this? Thank you.

    My problem is that it works well on a database and another data base, it is really slow.

    Kind regards

    Michael.

    Councils ORDERED to join the table in the order that they are put in the FROM clause. USE_NL oracle tips to use sweeping LOOP IMBRIQUEE.

    Here is an example. Find the order in which the tables are specified in the clause and the output of the execution plan.

    SQL> select /*+ ORDERED USE_NL(e d) */ d.dname, e.ename from emp e join dept d on e.deptno = d.deptno;
    ...
    ----------------------------------------------------------------------------------------
    | Id  | Operation                    | Name    | Rows  | Bytes | Cost (%CPU)| Time     |
    ----------------------------------------------------------------------------------------
    |   0 | SELECT STATEMENT             |         |       |       |     5 (100)|          |
    |   1 |  NESTED LOOPS                |         |    11 |   242 |     5   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL          | EMP     |    11 |    99 |     2   (0)| 00:00:01 |
    |   3 |   TABLE ACCESS BY INDEX ROWID| DEPT    |     1 |    13 |     1   (0)| 00:00:01 |
    |*  4 |    INDEX UNIQUE SCAN         | DEPT_PK |     1 |       |     1   (0)| 00:00:01 |
    ----------------------------------------------------------------------------------------
    Predicate Information (identified by operation id):
    ---------------------------------------------------
       4 - access("E"."DEPTNO"="D"."DEPTNO")
    
    SQL> select /*+ ORDERED USE_NL(e d) */ d.dname, e.ename from dept d join emp e on e.deptno = d.deptno;
    ...
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |       |       |     5 (100)|          |
    |   1 |  NESTED LOOPS      |      |    11 |   242 |     5   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| DEPT |     4 |    52 |     2   (0)| 00:00:01 |
    |*  3 |   TABLE ACCESS FULL| EMP  |     3 |    27 |     1   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    Predicate Information (identified by operation id):
    ---------------------------------------------------
       3 - filter("E"."DEPTNO"="D"."DEPTNO")
    
  • What is the meaning of the content under "information of Projection column (identified by the operation identity card)" in the output of dbms_xplan

    Hi Experts,

    I have a question to understand the output of the explain Plan. I'm on Oracle 11.2.0.2 on Linux. I use this command:

    Select * from table (dbms_xplan.display_cursor (null, null, 'All allstats'));

    In the output, there is a section like this:

    Projection of the column information (identified by the operation identity card):
    -----------------------------------------------------------

    2 (#keys = 1; upd = 6, 7; cmp = 1, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16; cpy = 1, 5, 6, 8) 'A1 '. "CLNT_OID" [VARCHAR2, 16], 'G2' "." " CLNT_OID "[VARCHAR2, 16]..."

    I'm not "what it means, and how this information will be used. I look at several presentations on the plan to explain it, but I don't have any explanation for this. Can someone explain what meanings, and how this information is useful?

    Thank you!

    OrauserN

    Can someone explain what meanings, and how this information is useful?

    Nothing more than general comments because does not have the validation of the application and the entire plan.

    This article shows the projections of the column used for the specific steps of the execution plan. Each step is the operation identity card which has links with the plan which would be normally shown BEFORE the one-liner you posted.

    A "projection" shows the actual columns for this stage located in the workplace. Occasionally, you will find that many more columns (and therefore data) are presented that are actually used.

    Here is an article which presents and discusses, an extreme example.

    http://alexanderanokhin.WordPress.com/2012/07/18/dont-forget-about-column-projection/

    This example compares the projections for the two versions of an application from MERGER. It's version 1

    Fusion in t1 with a t2 on (t1.id = t2.id)

    when matched, then update set n = 1;
    . . .
    Be careful on the projection of the column of steps 3, 4, 5. It contains all THE columns in the tables T1 and T2, even though the query uses only some of them.

    It is the second version of the application of the MERGER:

    Fusion in (select id, n from t1) t1 2

    using (select id, n of the t2) t2 on (t1.id = t2.id) 3

    When 4 correspondent then update the value n = 1;

    Now, projection of the column does not unnecessary, the amount of memory required and a result of temp space quantity columns contain (employee-Tmp ~ 16 MB) and i/o (2032 physical reads and 2032 physics written by direct path read temp and see direct writing temp) was significantly reduced, and the instruction was executed about 20 seconds, instead of 8 minutes.

    What article and for example, try to show is that projection section can help show how much data a plan works for a particular stage of the plan.

    This first version of MERGE seems very simple and easy to write, but as the author has pointed out, the projection indicates that all columns of the two tables were actually put in the workspace.

    The almost as simple rewrite version 2 run time reduced to 20 seconds to 8 minutes, mainly because of significantly less data handled.

  • What is the meaning of this statement.

    Of http://docs.oracle.com/cd/E11882_01/server.112/e16638/optimops.htm#autoId34, there is not that I can't understand.
    If the path of the inner table is independent of the external table, then the same lines are retrieved for each iteration of the outer loop, significantly reduce the performance of the.
    What is the meaning of this statement? You can take an example for me?

    Thanks
    Lonion

    >
    Of http://docs.oracle.com/cd/E11882_01/server.112/e16638/optimops.htm#autoId34, there is not that I can't understand.

    If the inner table's access path is independent of the outer table, then the same rows are retrieved for every iteration of the outer loop, degrading performance considerably. 
    

    What is the meaning of this statement? You can take an example for me?
    >
    Can you say: join Cartesian?

    This quote is from the section explaining the nested loops. and note it gives you a clue:
    >
    See also:

    "Cartesian joins.
    >
    The sentence BEFORE the one you quoted, it is what connects your quote with the MENTION:
    >
    It is important to ensure that the internal table is driven out of the external table (function).
    >
    This statement means that the lines of the internal table should DEPEND ON the external table.

    In a Cartesian join the inner table will depend on the external table at all:

    SELECT D.*, E.* FROM DEPT D, EMP E
    

    There is no WHERE clause, so there is nothing saying Oracle tables are related as well. Oracle will perform a Cartesian join and if a nested loop is used then, as says your quote, "the same lines are retrieved for each iteration of the outer loop, performance degradation significantly."

    All Oracle ranks visits to query external table lines will now be the inner table. But because there is no WHERE clause is no available information to EXCLUDE lines from the internal table "the same lines are extracted" (ALL) "for each iteration of the outer loop.

    Here is the same query above using the USE_NL hint to force Oracle to use a nested loop

    SQL> select /*+ use_nl (d e) */ d.*, e.* from dept d, emp e;
    
    56 rows selected.
    
    Execution Plan
    ----------------------------------------------------------
    Plan hash value: 4192419542
    
    ---------------------------------------------------------------------------
    | Id  | Operation          | Name | Rows  | Bytes | Cost (%CPU)| Time     |
    ---------------------------------------------------------------------------
    |   0 | SELECT STATEMENT   |      |    56 |  3248 |    10   (0)| 00:00:01 |
    |   1 |  NESTED LOOPS      |      |    56 |  3248 |    10   (0)| 00:00:01 |
    |   2 |   TABLE ACCESS FULL| DEPT |     4 |    80 |     3   (0)| 00:00:01 |
    |   3 |   TABLE ACCESS FULL| EMP  |    14 |   532 |     2   (0)| 00:00:01 |
    ---------------------------------------------------------------------------
    
    Statistics
    ----------------------------------------------------------
              1  recursive calls
              0  db block gets
             42  consistent gets
              0  physical reads
              0  redo size
           3897  bytes sent via SQL*Net to client
            452  bytes received via SQL*Net from client
              5  SQL*Net roundtrips to/from client
              0  sorts (memory)
              0  sorts (disk)
             56  rows processed
    
    SQL>
    
  • What is the best (global temporary Table or tables of Type Object)

    Dear all,

    I'll try to refine some code and find that we have a large loop that goes to loop over 100000 times and for each record, it in turn for validation of controls in individual tables.

    I intend to implement all of the functionality of controls using join conditions. I.e. to empty all the data into a global temporary table or tables oracle object type and apply the conditions of verification using join operations, so that I can avoid the unnecessary check for each record.

    If I want to implement this, I want to know what is best. A global temporary table or the Oracle Tables nested.

    Appreciate your response.

    Thank you
    MK.

    If you mean a global temporary table vs a variable from PL/SQL grouping, then 100 + lines is a lot to store in session memory a GTT would be so a more scalable solution. It will give you more options to manipulate the data using SQL.

    Note that a 'table of type object', or 'table object type' can mean a table of database (no PL/SQL) for example "CREATE TABLE MyTable mytype". However, I don't think you mean that.

  • What is the best way to deal with a 'Implicit coercion' in a table to a sprite?

    Hi all!

    With the continued support of this forum, I'm getting closer to have a programme of work. I can't wait to be able to help others like me once I've finished learning the ropes of AS3.

    I'll briefly explain what I want to achieve and then followed with my question.

    Background

    I created a random number of 12 x 9 grid that fills each cell with an image, based on the numeric value of each cell. I also have a random play button that makes random numbers in the grid. The problem I am running became my click event of button to erase the current images off the grid in order to allocate the new (for example by removing the objects display battery in order to place the new ones in the same places).

    Question

    My question is this: what is the best way to manage an implicit constraint from a table to a sprite? I pasted my complete code below so that you can see how the functions are supposed to work together. My sentence is apparently not being able to use a value from array with a sprite (sprite represents the real layout of the grid on the pile of display while the table starts as a number that is assigned an image that must be transmitted to the sprite).

    ============================================================================

    package
    {
    import flash.display.MovieClip;
    import flash.display.DisplayObject;
    import flash.events.MouseEvent;
    import flash.display.Sprite;
    import flash.text.TextField;
    import flash.text.TextFormat;
    import flash.utils.getDefinitionByName;

    SerializableAttribute public class extends MovieClip Blanko
    {
    Contains 12 * 9 grid of cells.
    var grid: Sprite;
    Maintains the shuffle button.
    var shuffleButton:Sprite;
    Is equal to 12 columns, 9 lines.
    var cols: int = 12;
    lines of the var: int = 9;
    Equal number of grid cells (108).
    cells var: int = COL * rows;
    Sets of cell width and height to 40 pixels.
    var cellW:int = 40;
    var cellH:int = 40;
    Contains 108 images of cell.
    var imageArray:Array = [];
    Contains 108 numerical values for the cells in the grid.
    var cellNumbers:Array = [];

    Constructor calls the functions "generateGrid" and "makeShuffleButton".
    public void Blanko()
    {
    generateGrid();
    makeShuffleButton();
    }

    Creates and displays the grid 12 * 9.
    private function generateGrid (): void
    {
    grid = new Sprite;
    var i: int = 0;


    for (i = 0; i < cells; i ++)
    {
    cellNumbers.push (i % 9 + 1);
    }
    trace ("before shuffle:", cellNumbers);
    shuffleCells (cellNumbers);
    trace ("after shuffle:", cellNumbers);
    var _cell:Sprite;

    for (i = 0; i < cells; i ++)
    {

    / / This line is where the implicit constraint occurs. '_cell' is a leprechaun trying

    on a temporary basis equal to a value from array.
    _cell = drawCells (cellNumbers [i]);
    _cell.x = (I % cols) * cellW;
    _cell.y = (I / COL) * cellH;

    grid.addChild (_cell);
    }
    }

    Creates a "shuffle" button and adds a mouse click event.
    private function makeShuffleButton (): void
    {
    var _label:TextField = new TextField();
    _label. AutoSize = 'center ';
    TextField (_label) .multiline = TextField (_label) .wordWrap = false;
    TextField (_label) .defaultTextFormat is new TextFormat ("Arial", 11, 0xFFFFFF, "bold");.
    _label. Text = "SHUFFLE";
    _label.x = 4;
    _label.y = 2;
    shuffleButton = new Sprite();
    shuffleButton.graphics.beginFill (0 x 484848);
    shuffleButton.graphics.drawRoundRect (0, 0, _label.width + _label.x * 2, _label.height +)
    _label.y * 2, 10);
    shuffleButton.addChild (_label);
    shuffleButton.buttonMode = shuffleButton.useHandCursor = true;
    shuffleButton.mouseChildren = false;
    shuffleButton.x = grid.x + 30 + grid.width - shuffleButton.width;
    shuffleButton.y = grid.y + grid.height + 10;
    this.addChild (shuffleButton);
    shuffleButton.addEventListener (MouseEvent.CLICK, onShuffleButtonClick);
    }

    Erase the images of the cell, mix of their numbers and then assigned these new images.
    private function onShuffleButtonClick (): void
    {
    eraseCells();
    shuffleCells (cellNumbers);
    trace ("after shuffle:", cellNumbers);


    for (var i: int = 0; i < cells; i ++)
    {
    drawCells (cellNumbers [i]);
    }
    }

    Deletes any existing cells in the battery of the display image.
    private void eraseCells(): void
    {
    While (imageArray.numChildren > 0)
    {
    imageArray.removeChildAt (0);
    }
    }

    Changes cell phones numbers (makes random table).
    private void shuffleCells(_array:Array):void
    {
    var _number:int = 0;
    var _a:int = 0;
    var _b:int = 0;
    var _rand:int = 0;

    for (var i: int = _array.length - 1; i > 0; i-)
    {
    _rand = Math.Random () * (i - 1);
    _A = _array [i];
    _B = _array [_rand];
    _ARRAY [i] = _b;
    [_Rand] _ARRAY = _a;
    }
    }

    Retrieves and sets a custom image to a cell based on its numerical value.
    private void drawCells(_numeral:int):Array
    {
    var _classRef: Class = Class (getDefinitionByName ("skin" + _numeral));
    _classRef.x = 30;
    imageArray.push (_classRef);
    imageArray.addChild (_classRef);
    return of demonstration;
    }
    }
    }

    ===========================================================================

    Any help with this is greatly appreciated. Thank you!

    If you want to have an array of Sprites that you later clear that is fine. But this does not mean that your function should return to it.

    You need your function to return the sprite so that you can add it to the display list and everything what you need.

    So just have the function get Sprite, push it in the "toBeClearedInTheFutureArray" and then return a reference to the currently acquired sprite.

  • Query SQL with multiple tables - what is the most effective way?

    Hello I learn PL/SQL. I have a simple procedure, where I need to find the number of employees and departments by location according to location_id user input.

    I have 3 Tables:

    LOCATIONS
    Location_id (pk)
    location_name
    ...
    DEPARTMENTS
    department_id (pk)
    Location_id (fk)
    department_name
    ....
    EMPLOYEES
    employee_id (pk)
    department_id (fk)
    Employee_Name
    ....

    1 location can have 0 - SEVERAL departments
    1 employee has 1 Department

    Here's the query I come up with for PL/SQL procedure:

    / * Ecount, Dcount are variable NUMBERS * /.

    SELECT SUM (EmployeeCount), COUNT (DepartmentNumber)
    IN Ecount, Dcount
    Of
    (SELECT COUNT (employee_id) EmployeeCount, department_id DepartmentNumber
    Employees
    GROUP BY department_id
    HAVING department_id IN
    (SELECT department_id
    Ministries
    WHERE location_id = userInput));

    I get the correct result, but I wonder if my query is on the right track and if there is a more "efficient" method to do so.
    Thanks in advance for help a beginner.

    Hello

    Welcome to the forum!

    Something like this will be more effective:

    SELECT    COUNT (employee_id)               AS ECount
    ,       COUNT (DISTINCT department_id)     AS DCount
    FROM       employees
    WHERE       department_id IN (     SELECT     department_id
                        FROM      departments
                        WHERE      location_id = :userInput
                      )
    ;
    

    You should also try a join instead of the IN subquery.

    For efficiency, do only the things you need to do.
    For example, you need not a number of employees in each Department, in order to not calculate one. This means that you will not need the notice online, so do not have.
    You needn't PL/SQL for this work, so don't use PL/SQL, if you do not have to (I know this question was out of context, then you may have good reasons to do this in PL/SQL.)

    Perform all the filtering as soon as possible. Do not waste it effort on the things that will not be used.
    An example of this is: never use a HAVING clause when you can use a WHERE clause. What is the difference between a WHERE clause and a HAVING clause? The WHERE clause is applied until the aggregate functions are calculated and the HAVING clause is applied after; There is no other difference. Therefore, if the HAVING clause is not reference an aggregate function, it could be done in a WHERE clause instead.

Maybe you are looking for

  • pls confirm 855-602-7992 is mozilla &amp; service of Cyber crime

    I was on the phone with very useful help system that I couldn't go to Mozilla - I've had for many years. I was told that my ip address has been hacked. Melvin was extremely helpful and told me that I needed a level 3 anti-piracy expert that my driver

  • ENVY 5534: Exchange HP60 cartridges for HP61?

    I just replaced my old ENVY 100 with a new 5534 ENVY, I opened HP60 black and trichromique print cartridges, but my 5534 WANT new uses of HP61. You can exchange the unopened HP60 for HP61?

  • Error compiling 2010 FPGA - TclTasklC:project_028: unknown property value

    Hi, I use a cRIO 9075 and a NI 9211 to measure the temperature to a project very busy with. Whenever I have try the code for compilation of t I have a compilation error which read as follows: Compilation failed due to an error of Xilinx. Details: ERR

  • How to get windows Vista if I forgot the password

    Well, I have a sony vios computer that I use for 6 years and have windows vista I need to use now but I forgot the password to access the system how can I do to get and change my password used again once I can not use the due recovery disk i have rec

  • Network profile

    Currently I have a network created in Public profile, but this network should be under network domain, what do I do to get it under the correct network profile? I try to remove the connection and recreate the connection, but still the same.