Value that has the most instances

Hello

I have a column and I want to know what values the most occurrences.
Oracle 10g.

Columna

CAT
DOG
DOG
HORSE

I would like to know it is DOG the value that appears most often.

Thank you

If you want only a single value, even if there is a tie, try:

SQL> WITH a AS
  2  (SELECT 'CAT' AS animal FROM DUAL
  3   UNION ALL
  4   SELECT 'DOG' FROM DUAL
  5   UNION ALL
  6   SELECT 'DOG' FROM DUAL
  7   UNION ALL
  8   SELECT 'HORSE' FROM DUAL)
  9  select max(animal) keep (dense_rank last order by count(*)) animal
 10  from   a
 11  group by animal;

ANIMA
-----
DOG

Nicolas.

Tags: Database

Similar Questions

  • find a value that is the most

    Let's say I have a column with different values, now I want to find a value located most, how is the best way to make this request?
    Is the best solution to do this way:
    WITH t AS
     (SELECT 'a' AS VALUE  FROM Dual  UNION ALL
      SELECT 'b'  FROM Dual  UNION ALL
      SELECT 'a' FROM Dual)
    SELECT VALUE
    FROM (SELECT t.Value, COUNT(*) AS Cnt
               FROM t
               GROUP BY t.Value
               ORDER BY Cnt DESC
              )
    WHERE Rownum = 1
    As you can see that the value 'a' is more time in table T, then the query must exit the 'a' and nothing more. If the number of occurrences of the 'a' and 'b' would be the same, then the application should exit one of them, no matter which.
    As you can see query now does not seem to be well optimized, I think.
    (Oracle 10g)

    Or

    SQL> with t
         as (
      select 'a' as value from dual union all
      select 'b' from dual union all
      select 'b' from dual
    )
    --
    --
    select max (value) keep (dense_rank last order by count (*)) value,
           count(*) cnt
      from t
    group by value
    /
    VALUE        CNT
    ----- ----------
    b              2
    1 row selected.
    

    Published by: MichaelS on December 14, 2010 10:39

    CNT added.

  • Configure replication vSphere fails - there is a virtual machine that has the same UUID instance than the one you are trying to configure

    Hi all


    My colleague was trying to extend a hard disk of a server 2008R2 who (1) had a snapshot and (2) was being replicated. The operation has failed and they took the snapshot replication can be stopped. Long story short when I got to him, the server could not be configured for replication and could not extend the disk and a vMotion failed.

    Looking at the files of the VM on the data store and the VMs .vmx file we have all the characteristics of a virtual machine always configured for replication of vSphere. If you try to configure replication vSphere causes an instant error "vsphere replication does not support change the length of a replicated disk. After a few changes I can reconfigure vSphere new replication, however, when the wizard has finished, I get a new error message (see below):

    "Try to set up vSphere that replication has failed for the VM"name vm"during the creation of groups"vm". There is a virtual "vm-name" machine that has the same instance UUID ' UUID of the Virtual Machine "that you want to configure. The existing vSphere of replication is configured for site protection.

    A possible solution would be to reset the database embedded VRMS our DR as suggested here VR configure replication after losing a VC site server but I was wondering if there is another solution? I have not reset the database of VRM before and cannot find a document that tells exactly what to do. I guess I need to stop all the rehearsals before resetting the database?

    See you soon,.

    Dean

    Hello

    There is no need to reset the VRMS database.

    If you know the value GID... an orphan replication, you can use the CROWD VRMS (https://vrms_address:8043/mob/?moid=GID-...&vmodl=1) to call the destroy method - it is eliminating simple replication to the site of the source or the target.

    If you don't know the GID... value, it can be found of VRMS DB or log files. Please file an SR for assistance.

    This procedure is already documented in internal KB articles and help using VMware support:

    KB article internal 2056086, section "cannot replicate virtual machine as there is another virtual machine with the same UUID instance"

    and also internal KB article 2060751.

    The admin guide section will be updated as it is confusing right now by suggesting only to reset the DB.

    Kind regards

    Martin

  • Wlhich is the last Photoshop that has the oil paint filter?

    Who is the most recent Photoshop that has the filter of the oil it painting?  What is CS6?   or CC?

    Is there a substitute that is known for the oil paint filter?

    Thank you! Now, I try to install the CC.  I appreciate it!

  • I'm a window that has the windows displayed in yahoo mail and hadou and I can click on one of the images of a window and it will restore the window how?

    I am in yahoo mail and there is a window that has the windows displayed and I can click on one of the images of a window and it will restore the window how to access this window (size full one who possesses a collection of previous windows in a complete graph/no format)?
    The window that I write the topic is a collection of previous windows images in a smaller size.

    Firefox has a feature to view all your open tabs in one or more groups of tabs. You can show and hide this screen by pressing Ctrl + Shift + e. Is this the one you see, or something different?

    If you ended up with more than a group of tabs and you want to consolidate them, you can drag the thumbnail images all in one group.

    More information: use tab groups to organize a large number of tabs.

  • Sometime this week, my MacBook Pro has lost its sound. I can't listen to anything that has the sound of iTunes for video clips. It is no longer a Volume icon (speaker w / lines of radiation) on my Menu bar

    Sometime this week, my MacBook Pro has lost its sound. I can't listen to anything that has the sound of iTunes for video clips. It is no longer a Volume icon (speaker w / lines of radiation) on my Menu bar. My MacBook Pro is a mid-2012, 2.3 GHz Intel Core i7 Memory 16 GB 1600 MHz DDR3 OS X Version Yosemite 10.10.5

    Graphics Intel HD 4000. Can anyone help?

    Thank you very much!

    Thai-Anh

    Reset NVRAM may solve it.

    How to reset the NVRAM on your Mac - Apple Support

    Or system preferences > sound, check on 'Volume to see the menu bar' to show the volume of the sound in the menu bar.

  • If I put all my files on the C drive that has the operating system and make a recovery of keys one, will I lose my files?

    If I put all my files on the C drive that has the operating system and make a recovery of keys one, will I lose my files? drive C whereas the partition that has the operating system and drive D is the lenovo drive that has all the drivers lenovo and all those. Did I lose my files?

    Yes, the collection clears all of the C drive and you will lose your files. The solution would be to backup regularly to an external HARD drive and after the key one to also restore the files from the external hard drive.

    This has been answered before, if you do a search for "key recovery" it appears among the first results.

    http://forums.Lenovo.com/T5/IdeaPad-Y-U-V-Z-and-P-series/will-i-lose-my-files-if-i-do-one-key-recove...

  • How can I do a vi that has the letters of a text

    Please help me, I do a vi that has the letters of a text I give in a string. I tell him what letter back from the text. I'm using labview 6

    As LV6 missing probably the find and replace String cleverly, you can always do:

  • How can I move the outlook express emails from an XP PC to an another XP PC that has the same e-mail address without overwriting existing messages on this second PC?

    How can I move the outlook express emails from an XP PC to an another XP PC that has the same e-mail address without overwriting existing messages on this second PC?

    I need to group together all messages from e-mail in a PC and to retire the first PC.

    This could be problematic. I guess or OE is over? This would make it easy.
     
    One thing you could do requires some manual work, but much less removal of dupes. For example, the Inbox. In the machine, you are going to scrap, create a new folder and move all messages in your Inbox to it. After you import on the other machine, you can drag the messages you need this folder in the Inbox, and then remove the user created the folder.
     
    And then there are tools to remove the dupes. This one for example.
     

     
     
  • I got a CD with a file that has the extension .mdb. What are my options to open and view this file? Secondly, the recommendation for pc virus protection?

    I have a HP with Windows Vista Premium installed.  I got a CD with a file that has the extension .mdb.   What are my options to open and view this file?    There is a second file on the disk with an extension .ldb.   What kind of file is it?

    Second, the recommendations that you offer for pc virus protection?   My coverage of Trend Micro systems allows access to the Explorer after I disable add ons... while I am limited with respect to the capabilities of the computer.

    Thank you!

    .Mdb and .ldb file extensions are used by the Microsoft Access database program. .mdb is a .ldb file is a lock file. You may be able to consult the data base with Access runtime, downloadable here:

    http://www.Microsoft.com/downloads/en/details.aspx?FamilyId=d9ae78d9-9DC6-4b38-9fa6-2c745a175aed&displaylang=en

    For an antivirus that doesn't interfere too much, try Microsoft Security Essentials:http://www.microsoft.com/security_essentials/?mkt=en-us . Ensure that anti-virus programs are completely removed, with vendors removal tool, preferably before installation.

  • An encyclopedia of DVD that has the same appearance as Encarta.

    Original title: equivalent of Encarta?

    I was disappointed in Britannica. Narrow, not easy to see or read, dull graphics.

    I believe that Encarta is inspired, the equivalent of, another popular encyclopedia. Of maybe Compton?

    I hope that a fellow fan of Encarta may suggest a DVD encyclopedia that has the same appearance as Encarta.

    Bing and Google will show that the Britannica is the only one left. Bing and Google also make a much better and more current still reference...

  • What is the name of the table that has the name of the custom in the Oracle database Section?

    What is the name of the table that has the name of the custom in the Oracle database Section?

    Thank you

    Nefertari

    The names of the custom Sections are stored in commonExtendedAttributeML, the extended attribute table.

  • Mr President, how can I enter two rows at the same time with different default values that only the first line to use see?

    Mr President.

    My worm jdev is 12.2.1

    How to enter two rows at the same time with different default values that only the first line to use see?

    Suppose I have a table with four fields as below

    "DEBIT" VARCHAR2(7) , 
      "DRNAME" VARCHAR2(50),
      "CREDIT" VARCHAR2(7) , 
      "CRNAME" VARCHAR2(50),
    

    Now I want that when I click on a button (create an insert) to create the first line with the default values below

    firstrow.png

    So if I click on the button and then validate the second row with different values is also inserted on commit.

    The value of the second row are like the picture below

    tworows.png

    But the second row should be invisible. It could be achieved by adding vc in the vo.

    The difficult part in my question is therefore, to add the second row with the new default values.

    Because I already added default values in the first row.

    Now how to add second time default values.

    Concerning

    Mr President

    I change the code given by expensive Sameh Nassar and get my results.

    Thanks once again dear Sameh Nassar .

    My code to get my goal is

    First line of code is

        protected void doDML(int operation, TransactionEvent e) {    
    
            if(operation != DML_DELETE)
                 {
                     setAmount(getPurqty().multiply(getUnitpurprice()));
                 } 
    
            if (operation == DML_INSERT )
                       {
                               System.out.println("I am in Insert with vid= " + getVid());
                           insertSecondRowInDatabase(getVid(),getLineitem(),"6010010","SALES TAX PAYABLE",
                            (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));      
    
                           }
    
            if(operation == DML_UPDATE)
                              {                                                    
    
                                 System.out.println("I am in Update with vid= " + getVid());
                             updateSecondRowInDatabase(getVid(),
                                 (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));      
    
                              }                      
    
            super.doDML(operation, e);
        }
        private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4, Object value5)
                  {
                    PreparedStatement stat = null;
                    try
                    {
                      String sql = "Insert into vdet (VID,LINEITEM,DEBIT,DRNAME,AMOUNT) values " +
                 "('" + value1 + "','" + value2 + "','" + value3 + "','" + value4 + "','" + value5 + "')";  
    
                      stat = getDBTransaction().createPreparedStatement(sql, 1);
                      stat.executeUpdate();
                    }
                    catch (Exception e)
                    {
                      e.printStackTrace();
                    }
                    finally
                    {
                      try
                      {
                        stat.close();
                      }
                      catch (Exception e)
                      {
                        e.printStackTrace();
                      }
                    }
                  }  
    
                  private void updateSecondRowInDatabase(Object value1, Object value5)
                  {
                    PreparedStatement stat = null;
                    try
                    {
                      String sql = "update vdet set  AMOUNT='"+ value5+"' where VID='" + value1 + "'";                     
    
                      stat = getDBTransaction().createPreparedStatement(sql, 1);  
    
                      stat.executeUpdate();
                    }
                    catch (Exception e)
                    {
                      e.printStackTrace();
                    }
                    finally
                    {
                      try
                      {
                        stat.close();
                      }
                      catch (Exception e)
                      {
                        e.printStackTrace();
                      }
                    }                  
    
                  }
    

    Second line code is inside a bean method

        public void addNewPurchaseVoucher(ActionEvent actionEvent) {
            // Add event code here...
    
            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();
                   DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("VoucherView1Iterator");
                   RowSetIterator rsi = dciter.getRowSetIterator();
                   Row lastRow = rsi.last();
                   int lastRowIndex = rsi.getRangeIndexOf(lastRow);
                   Row newRow = rsi.createRow();
                   newRow.setNewRowState(Row.STATUS_NEW);
                   rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow);
                   rsi.setCurrentRow(newRow);
    
                   BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry();
                   DCIteratorBinding dciter1 = (DCIteratorBinding) bindings1.get("VdetView1Iterator");
                   RowSetIterator rsi1 = dciter1.getRowSetIterator();
                   Row lastRow1 = rsi1.last();
                   int lastRowIndex1 = rsi1.getRangeIndexOf(lastRow1);
                   Row newRow1 = rsi1.createRow();
                   newRow1.setNewRowState(Row.STATUS_NEW);
                   rsi1.insertRowAtRangeIndex(lastRowIndex1 +1, newRow1);
                   rsi1.setCurrentRow(newRow1);
        }
    

    And final saveUpdate method is

        public void saveUpdateButton(ActionEvent actionEvent) {
            // Add event code here...
    
            BindingContainer bindingsBC = BindingContext.getCurrent().getCurrentBindingsEntry();      
    
                   OperationBinding commit = bindingsBC.getOperationBinding("Commit");
                   commit.execute(); 
    
            OperationBinding operationBinding = BindingContext.getCurrent().getCurrentBindingsEntry().getOperationBinding("Commit");
            operationBinding.execute();
            DCIteratorBinding iter = (DCIteratorBinding) BindingContext.getCurrent().getCurrentBindingsEntry().get("VdetView1Iterator");// write iterator name from pageDef.
            iter.getViewObject().executeQuery();  
    
        }
    

    Thanks for all the cooperation to obtain the desired results.

    Concerning

  • I am currently working on a site that has the integration of Paypal which includes the page redirects (confirm or cancel). My goal is to have the implementation of site with a layout for desktop, Tablet and phone. My question is when I have a redirect pag

    I am currently working on a site that has the integration of Paypal which includes the page redirects (confirm or cancel). My goal is to have the implementation of site with a layout for desktop, Tablet and phone. My question is when I have a redirect page should I create a separate provision of the page for each device or just a provision of office that fits all three screen sizes? I hope that if the html page has the same name of the device (query) is automatically detected. Help with the help of Adobe Muse CC

    By Payal integration, you mean paypal html button? or etc payment gateway configuration? If this is a configuration of the gateway to your site domain name then a single page with any structure will work, but if you use the button code for all associated formats then you will need to create separate pages for all.

    Thank you

    Sanjit

  • Synchronize the folder removes the PNG files if there is a JPG file that has the same file name

    I often use the folder to synchronize and noticed that he tries to delete my PNG file if there is a JPG file that has the same file name. There is no problem with their import, Assembly, etc...

    The only solution is to disable the ' Remove missing photos in the catalog "on the prompt window synchronize folder so it does not remove it catalog.

    I have the latest version of Lightroom for Windows (v5.6) but it happened in previous versions on both Mac and PC.

    If someone has noticed this?

    -Pete

    "Treat the RAW + JPG as separate folders" enabled or not in preferences?

Maybe you are looking for

  • Is my download of firefox is limited to the bottom of my ISP?

    My internet connection is fine, my computer is clean and works perfectly, but every time I try to download firefox so I can stop using IE (which is absolute garbage), it downloads about 3 KB/s. Is this a problem with the software open source or is my

  • LabVIEW Web Services: How "undeploy" web services

    I created the example of web services: Address book in book labview\examples\comm\webservices\address project for an example of a Web service that handles to publish data, streaming output, static content and HTML Forms. Weather project monitor labvi

  • Earphones or headphones

    I was using the earbuds that come with the Clip + and was disappointed that even at the highest setting (and with an equal level up), I could barely hear my music.  Today, I tried to use the regular helmet and was surprised to see the difference.  No

  • Preview pane does not work for photos

    When I open the My picture folder, I can't preview any photo. I just get the default icon. How can I view the picture without opening it? File extensions are almost all .jpg It worked well in XP Pro. I am now using Windows 7 Home Premium

  • Free ads in app purchase

    Not sure if this is the right forum but; I have ads in my application and want to add a free ad version as an application to buy how could achieve this. IM had to expand so as simple as possible would be thank you very much. It would also be a C++ fu