Oracle Training Oracle Support Development Oracle Apps

 E-mail Us
 Oracle Articles
New Oracle Articles

 Oracle Training
 Oracle Tips

 Oracle Forum
 Class Catalog

 Remote DBA
 Oracle Tuning
 Emergency 911
 RAC Support
 Apps Support
 Oracle Support

 SQL Tuning

 Oracle UNIX
 Oracle Linux
 Remote s
 Remote plans
 Application Server

 Oracle Forms
 Oracle Portal
 App Upgrades
 SQL Server
 Oracle Concepts
 Software Support

 Remote S


 Consulting Staff
 Consulting Prices
 Help Wanted!


 Oracle Posters
 Oracle Books

 Oracle Scripts

Don Burleson Blog 







Linda Webb

Got breaking Oracle news?    Burleson Consulting Oracle News

Click here for more Oracle News Headlines


Counting with Oracle SQL

DBAsupport has published an excellent overview of how to use Oracle SQL for counting operations:

It also shows how the sum() and decode() operators can be used to count occurrences within an Oracle table:

Other than changing your database model to handle this more effectively, here is a simple method in Oracle that you can use to accomplish this. Please note that even though this works, you must know the possible values in the BREED_SIZE column that you want to turn into columns.

SQL> SELECT country,
            SUM(DECODE(breed_size,'Big'   ,1,0)) Big,
            SUM(DECODE(breed_size,'Medium',1,0)) Medium,
            SUM(DECODE(breed_size,'Small' ,1,0)) Small
       FROM dog_origin
      GROUP BY country
COUNTRY             BIG     MEDIUM      SMALL
------------ ---------- ---------- ----------
Australia             0          1          1
Germany               3          0          0
Switzerland           2          1          0
USA                   1          2          0


Oracle Training at Sea
oracle dba poster

Follow us on Twitter 
Oracle performance tuning software 
Oracle Linux poster


Burleson is the American Team

Note: This Oracle documentation was created as a support and Oracle training reference for use by our DBA performance tuning consulting professionals.  Feel free to ask questions on our Oracle forum.

Verify experience! Anyone considering using the services of an Oracle support expert should independently investigate their credentials and experience, and not rely on advertisements and self-proclaimed expertise. All legitimate Oracle experts publish their Oracle qualifications.

Errata?  Oracle technology is changing and we strive to update our BC Oracle support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:  

and include the URL for the page.


Burleson Consulting

The Oracle of Database Support

Oracle Performance Tuning

Remote DBA Services


Copyright © 1996 -  2017

All rights reserved by Burleson

Oracle ® is the registered trademark of Oracle Corporation.

Remote Emergency Support provided by Conversational