What is the most efficient SQL to identify the best 5 count indictment and the rest of the Group?

Hi all

I expect advice about the best way to solve the following (without use of subqueries and decode etc.):

We have a person table that includes the nationality column... we want to identify the top 5 (County) nationalities and the remaining sum is considered to be "the other". We would then use this result to create a pie for the organization chart.

Thanks in advance for your time.

Kind regards
Yahya

Or for example

SQL> select   object_type, sum (cnt) cnt
    from   (select   case when rownum <= 5 then object_type else 'OTHER' end object_type,
                     cnt
              from   (  select   count ( * ) cnt, object_type
                          from   all_objects
                      group by   object_type
                      order by   count ( * ) desc))
group by   object_type
order by   2 desc
/
OBJECT_TYPE                CNT
------------------- ----------
SYNONYM                  26932
JAVA CLASS               22203
OTHER                    10357
VIEW                      5064
INDEX                     4826
TABLE                     3232

6 rows selected.

Published by: michaels2 on July 1st, 2009 19:49

Tags: Database

Similar Questions

  • 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 value mentioned in the 'group' in the form of definition list of choices.

    What is the group in the form of definition list of choices. Is this something I need to create a group first and then assign it here or just type a group, it will be created?

    I created a list of choices like below

    (2) created a sandbox and a search box with list drop down option in the console of sysadmin. (not as a searchable list of choice).

    (3) created a sanbox in the console of the identity and trying to add a list of value of the ADF, nothing is coming (not able to see the field).

    For this field of type lookup should I select only one ADF option or select one choice, instead of the ADF value entry list?

    Please suggest.

    Hello

    On the creation of research of the Group field is just for research or to specify as a result of research belonging to a specific group. For example, you can specify your specific project for all custom research chain, that you created so that in the end, you can recognize your custom research and research OOTB.

    The user interface component is depend on your condition for example if you want dropdown and a single value undergo framework that you can use selectonechoice ADF and ADF LOV alone is different where all values given in different pop up and on the selection of a value of the same value obtained on LOV but I have tested this web composer LOV component and don't forget not there is a problem with this element of the adf. I added outside rather than web composer LOV.

    To try and discover what ADF UI component is adapted to your condition by activating your sandbox and when you finalize the component that only publish your sandbox.

    Kind regards

    Shantanu

  • What is the difference between the Group and join?

    I understand what is the grouping of contacts. and I saw the impact of joinging contacts but why would I do that? He takes the contacts that join off the my list of good contacts individuals list is deleted and all that remains is the name of the principal that joined you.

    Why do this?

    If you have the same contact in more than one group of Gmail, the droid will join them together. This prevents duplicates appear in the contacts list.

  • 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.

  • What are the best practices for a new employee to learn inside the instance of their business of Eloqua as efficiently as possible?

    We have companies everything changed at some point in our lives. And we all go through the process in the first weeks, where you feel new and are just trying to figure out how not to get lost on your way in the mornings.

    On top of that, trying to familiarize yourself with your new company Eloqua instance can be a daunting task, especially if it's a large organization.

    What are the best practices for new employees to learn as efficiently and effectively as possible?

    I am in this situation right now. Moved to a much larger organization. It is a huge task trying to understand all the ins and outs not only society, but also of the eloqua instance, especially when she is complex with many points of integration. I find that most of the learning happens when I really go do the work. I spent a ton of time going through the programs, documentation, integrations, etc., but after awhile, it's all just words on a page and not absorbed.

    The biggest thing that I recommend is to learn how and why things are made the way they are currently, ask lots of questions, don't assume not that things work the same as they did with your previous employer.

    Download some base in place level benchmarks to demonstrate additional improvement.

    Make a list of tasks in the long term. As a new pair of eyes, make a list of things you'd like to improve.

  • 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 order of the removal of the songs to an iPod Classic syncing &gt; somehow my laptop has started the process of synchronization without my knowledge and removed approximately 2,000 songs of my iPod classic.  How can I identify which were delete

    What is the order of the removal of the songs to an iPod Classic syncing > somehow my laptop has started the process of synchronization without my knowledge and removed approximately 2,000 songs of my iPod classic.  How can I identify which were deleted songs?  I always manually move files to prevent this.  I'm on Windows 10.

    Has no way to know that...

    If your library iTunes music fits on the storage space of 160 GB of your iPod classic, you just set to automatically sync your entire library of music.  Then, it won't matter which has been removed and which do not get deleted, because your iPod music library is the same as your library iTunes music.  And iTunes it keeps this way, every time your iPod connection (or click sync , if already connected).

    If you don't want "everything" in your iTunes library on your iPod (understandable), you can create a playlist in your iTunes library with all the songs you want on the iPod.  Then, set to automatically synchronize the playlist to iPod.  Instead of manually managing iPod, you manually manage playlist in your iTunes library.  The iPod has no need to be connected.  The next time you connect the iPod (or click sync , if already connected), iTunes will update the iPod with the same changes.  The big advantage is, if something happens like what you describe, or needs to restore iPod (erased) or even if break you your iPod (and get a new), need you a few mouse clicks to solve the problem.  Just set it up to sync the same playlist once again, which exists in your library iTunes (not only on the iPod).

    You can post back for more information about how to use automatic synchronization to do what you want more easily, go ahead.

  • What is the most likely thing the thief of my iPhone 6 has done?

    Hi, I was wondering if someone can help me please.
    Sunday night, stole my iPhone 6. (I have the last iOS9 updated on this subject). Fortunately, I was with a friend at the time and she called my phone and it went straight to voicemail without ringing, which means that the thief either it turns off, took out the sim card is placed on airplane mode.
    I came home about two hours later and immediately then icloud.com and saw that my phone is in offline mode - so I put my camera in mode for when the person finally lit it. 2 hours later, they it on and immediately off to new, probably unable to do anything whatsoever since I'd put it lost mode.

    None of my data has been consulted for as far as I can tell - I changed all my passwords just in case.

    It is now Monday evening and my iPhone is ALWAYS appear offline.

    What is the most likely thing the thief did? He sold it to a workshop of repairs for parts? Out the sim card? It is able to hack my phone is in airplane mode?

    Thank you.

    Sold for parts

  • What are the changes that the installation of BizTalk has on the SQL instance?

    Original title: BizTalk.

    Hello.

    I want to install BizTalk.
    BizTalk and SQL are different servers.
    I would like to know what are the changes that the installation of BizTalk on the SQL instance.
    Can anyone help?
    Thkz

    Hello

    I know it's late to answer this question, just in case someone else look through this issue.

    BizTalk installation does nothing to SQL Server, but make BizTalk Configuration. When configure us BizTalk on any SQL Server (same or different), it creates the required databases and SQL Server works on this server.

    Here is a series of articles on installing and configuring BizTalk Server: http://sandroaspbiztalkblog.wordpress.com/2013/05/16/biztalk-2013-installation-and-configuration-install-and-configure-biztalk-server-2013-part-9/

    Thank you!

  • What is the most important difference between 3D Picture control and controlling the display of Simulator

    I want to create a simulation of 3D on the front panel, and I see that we can use a 3D image control or a display of Simulator control. It seems that each of them can be used at the same position. What is the most important difference between 3D Picture control and display of Simulator?

    Hi sfh1,

    You are right, I found examples of Robotics that use 3D photo control and display Simulator control to display a scene 3D on the front panel. After further research, it seems that control the display of Simulator adds additional features compared to the 3D picture control. The control displays Simulator allows the user to right-click control during execution and change the background color, draw fashion, draw contact, view the ID of robot, display sensor data, suspension of service Simulator and reset service Simulator.

    More in depth on these options and the display of control Simulator can be found here:

    http://zone.NI.com/reference/en-XX/help/372983D-01/lvrobogsm/robo_controls_concepts/

    If you would like more information on the picture here 3D control is another resource:

    http://www.NI.com/white-paper/3170/en/#toc2

    Kind regards

  • I have WINDOWS XP, run office 97 / Access 97. What is the most recent windows that run these?

    I have WINDOWS XP, run office 97 / Access 97.  That's all

    I really need and want in the categories of personal finance.

    However, I need a more powerful and faster computer for our world today.

    What is the latest computer and office versions that will run office 97 / Access 97?

    Office 97 is not compatible with any version of victory, win7 & win8 and is no longer supported (no update security)

    Most of the problems are with outlook, so if you install, custom Setup to not include outlook, for a \Office97 \Program Files (x 86) folder

    If using win7 see this first Ko http://support.microsoft.com/kb/978591 if this applies also to the win8, I cannot say.

    If you are using win7 Pro (not the Home version) you can use virtual Windows XP and install Office 97 in this environment.

    Office 2007 and especially relies entirely on win7 & win8

    A more powerful/fast PC will make no difference for Office 97

  • What is the date of end SQL server 2008 SP2 support?

    What is the date of end SQL server 2008 SP2 support?

    Have you tried Google? or:

    ASK THE QUESTION IN THE SQL SERVER FORUM:
    http://social.msdn.Microsoft.com/forums/en/category/SQLServer

  • When I start the computer, sometimes the icon in the taskbar indicates that it is connected to a network that is not identified. I wait a few minutes until what he says at last he is identified & seems to work very well.

    Original title: Internet wireless connection

    I use a PC & a cable modem wireless to connect to the Internet.  When I start the computer, sometimes the icon in the taskbar indicates that it is connected to a network that is not identified.  I wait a few minutes until what he says at last he is identified & seems to work very well.  The only other issue I see is once in a while after it is connected, I noticed that it is to identify the network connection, but I see no problem to surf the web.  This could be a looming problem with the modem, or is it something else?  Should I consider it as my modem is still under warranty?  ARRIS / Motorola wants to charge a diagnostic fee is why I write on this forum first.

    Thank you

    [Transferred from Internet Explorer]

    Roll up your sleeves & cross your fingers...

    ACTIONS:

    [You can print these instructions for reference offline. DON'T SKIP ANY STEP! [If a step said to restart, restart!]

    1. click right on the link following, select SAVE TARGET as.... & download the Norton Removal Tool, save it to your desktop: ftp://ftp.symantec.com/public/english_us_canada/removal_tools/Norton_Removal_Tool.exe

    1. right click on the following link, select SAVE TARGET as... & download the McAfee consumer products removal tool, save it to your desktop: http://download.mcafee.com/products/licensed/cust_support_patches/MCPR.exe

    2. close all open applications (that is, anything with an icon on the taskbar).

    3. right click on the file that you saved in step # 1 above and select run as administrator to run the Norton utility. DO TAP not your keyboard until the race ends, then restart.

    3B. right-click on the file that you saved in step # 1 b above and select run as administrator to run the McAfee utility. DO TAP not your keyboard until the race ends, then reboot again.

    4. right-click on the following link and SAVE the download to your desktop: http://iefaq.info/attachments/133/ie8-rereg.zip [1]

    Note: Good for IE9, too.

    4B. right click on the file downloaded in # 4 above has (that is, ie8 - rereg.zip) and EXTRACT its contents to the desktop. This will create a new folder on your desktop namedie8-rereg.

    4 c. close all open applications (that is, anything with an icon on the task bar), open the new folder created in # 4 b above, double-click on the file ie8 - rereg.cmd to run the script and restart.

    5 reaffirm Internet Explorer as the browser in the default CUSTOM (<>) Set Program Access and defaults of the computerarticle. [2]

    6. reset Internet Explorer according to the instructions on this page: http://windows.microsoft.com/en-us/internet-explorer/reset-ie-settings

    Note => for best results, check the option Remove personal settings .

    7. open Internet Explorer (only!) to http://windows.microsoft.com/en-us/windows-vista/windows-update-error-8000ffff [ignore the title & symptoms].

    8 b. ignorant of the "not recommended" or similar warnings, run the difficulty (50202 #) DEFAULT modes and AGGRESSIVE. [3]

    9 restart once again & test.

    10. in response to this post with a status report.

    ==================================================
    [1] source: http://iefaq.info/index.php?action=artikel&cat=42&id=133&artlang=en

    [2] after that we ended up this thread, do not hesitate to reaffirm one of your other default browsers.

    [3] full Disclosure: the difficulty operating in AGGRESSIVE mode will remove your update history but not the list of installed updates.

  • not enough memory. What is the most affordable to increase memory

    What is the most affordable to increase memory

    Try increasing the size of virtual memory (it's free), as shown here: http://windows.microsoft.com/en-CA/windows-vista/Change-the-size-of-virtual-memory

    Virtual memory is slower, but if you do not use your PC to play or run programs like photoshop, you won't notice this fact.

Maybe you are looking for

  • RSS feeds will be updated and update

    I noticed yesterday that my news feeds are all from 3 days, around the same time I got my battery. All subscriptions have an arrow green-MSNBC, Digg etc. but not new news. I can't find any kind of discount anywhere settings. All MotoGurus ideas? Than

  • tab refnum compel dot

    Hello I created a simple Subvi (attached), that I would use whenever I need activate or disable the States of a TAB control. However I can see there is a point of stress when I connect a reference to the refnum TABcontrol input terminal. I'm not fami

  • Failed to update Windows

    is there a script to do the steps listed, it seems that nobody apply manually each step one by one unless of course their update service everything is broken

  • Canon camera does not

    Thank you, Andy, I like to think that this will help me (and others out there too). However, novices owe us a little more in detail with our instructions. What is a chipset? How reinstall us them? Or, is to reinstall the chipset just the procedure yo

  • Mplayer2 and msdxm.ocx problem on vista 64 OS

    I just installed the Vista 64 operating system.  When I try to run the old mplayer2 Windows Media Player, I get the following error: Mplayer2.exe - Entry Point not foundThe procedure entry point RunDIIW could not be located in the dynamic link librar