How Oracle performs with 'COUNT' when to go with "GROUP BY"?

Hello

I am aware that count return 0 there is still no data found a 'WHERE' clause

However, when he goes with "GROUP BY", he goes to the "EXCEPTION block".

declare

a number: = 0;

Start

Select COUNT (1) in the doubles where 1 = 2

Group 1;

dbms_output.put_line ('a =' | a);

exception

While OTHERS then

dbms_output.put_line ('Exception =' |) SQLERRM);

end;

/

output:

Exception = ORA-01403: no data found

Why is Oracle jumps in the 'EXCEPTION' block when "GROUP BY" is added?

Why may not behave in the same way as it did without "GROUP BY"?

Please help me understand.

Hello

11fdb98c-D100-4baa-8eee-c00c9f7303bc wrote:

Hello

I am aware that count return 0 there is still no data found a 'WHERE' clause

...

This is not true.  A query using COUNTY won't necessarily produce anything.  The query you posted is an example:

Select COUNT (1) in DOUBLE where 1 = 2

Group 1;

does not 0; It produces nothing at all.

Why is Oracle jumps in the 'EXCEPTION' block when "GROUP BY" is added?

SELECT... INTO will trigger an error ("no data found" or "too many rows"), except if the query produces exactly 1 row.

Why may not behave in the same way as it did without "GROUP BY"?

GROUP BY means that the query will produce 1 row of output for each group (after the WHERE clause has been applied).

A query using an aggregate (such as COUNT) without a GROUP BY clause function will always produce exactly 1 row.  (If you have a HAVING clause, then it can remove this row from the result set.)

What you trying to do?

Why do you use a GROUP BY clause in this case?  If you want a query which behaves as if it doesn't have a GROUP BY clause, then do not add a GROUP BY clause.

Tags: Database

Similar Questions

  • [ADF, JDev12.1.3] af:table: how to perform certain actions when the user clicks on a line?

    Hallo,

    When a line of my af:table is selected, I'd like to perform actions; in particular, I have to toggle a button based on the values of a group of fields to the selected line.

    What are the possible approaches to achieve this?

    Thank you

    Federico

    Use a generic selection listener (http://www.oracle.com/technetwork/developer-tools/adf/learnmore/23-generic-table-selection-listener-169162.pdf) and call your actions here before or after the selection of the new current line.

    Timo

  • How oracle (10.1) decides when the week begins, ends?

    Hello friends,

    I'm bundling a week in my query.

    The oracle instance is running on my computer: Red Hat Linux 5, the locale for starting oracle is provided below.

    From my point of view, my week started on 31/01/2010 (Sunday) and ends at 2010-06-02 (Saturday).
    Yet my oracle thinks differently: as can be seen in the example below, the 5th week begins on 29/01/2010 and ends on 02/05/2009.

    Why is this behavior?
    How can I control it, and how do I adjust for i18n?

    Thank you
    Maxim

    [oracle@mldev2 ~]$ locale
    LANG=en_US.UTF-8
    LC_CTYPE="en_US.UTF-8"
    LC_NUMERIC="en_US.UTF-8"
    LC_TIME="en_US.UTF-8"
    LC_COLLATE="en_US.UTF-8"
    LC_MONETARY="en_US.UTF-8"
    LC_MESSAGES="en_US.UTF-8"
    LC_PAPER="en_US.UTF-8"
    LC_NAME="en_US.UTF-8"
    LC_ADDRESS="en_US.UTF-8"
    LC_TELEPHONE="en_US.UTF-8"
    LC_MEASUREMENT="en_US.UTF-8"
    LC_IDENTIFICATION="en_US.UTF-8"
    LC_ALL=
    [oracle@mldev2 ~]$ file /etc/localtime
    /etc/localtime: symbolic link to `/usr/share/zoneinfo/Israel'
    SQL> select TO_CHAR(TO_DATE('28-JAN-2010'), 'WW YYYY') week from dual;
    -------
    04 2010
    
    SQL> select TO_CHAR(TO_DATE('29-JAN-2010'), 'WW YYYY') week from dual;
    -------
    05 2010
    
    SQL> select TO_CHAR(TO_DATE('30-JAN-2010'), 'WW YYYY') week from dual;
    -------
    05 2010
    
    SQL> select TO_CHAR(TO_DATE('31-JAN-2010'), 'WW YYYY') week from dual;
    -------
    05 2010
    
    SQL> select TO_CHAR(TO_DATE('01-FEB-2010'), 'WW YYYY') week from dual;
    -------
    05 2010
    
    SQL> select TO_CHAR(TO_DATE('02-FEB-2010'), 'WW YYYY') week from dual;
    -------
    05 2010
    
    SQL> select TO_CHAR(TO_DATE('03-FEB-2010'), 'WW YYYY') week from dual;
    -------
    05 2010
    
    SQL> select TO_CHAR(TO_DATE('04-FEB-2010'), 'WW YYYY') week from dual;
    -------
    05 2010
    
    SQL> select TO_CHAR(TO_DATE('05-FEB-2010'), 'WW YYYY') week from dual;
    -------
    06 2010
    
    SQL> select TO_CHAR(TO_DATE('06-FEB-2010'), 'WW YYYY') week from dual;
    -------
    06 2010
    
    SQL> select TO_CHAR(TO_DATE('07-FEB-2010'), 'WW YYYY') week from dual;
    -------
    06 2010

    Hello

    Beginning of the week is decided by NLS parameter's settings nls who decide NLS_TERRITORY.

    If you want your week should begin with Sunday not to use "WW" (according to NLS_TERRITORY), instead use 'IW', it doesn't depend of parameter nls.

    Concerning
    Anurag.

  • How to perform an action when the button is clicked reply all in BB email?

    I find the solution on below scenario, any help appriciated.

    User open a receipt email and click the 'reply to all' "."

    It is possible to perform any action on the button 'reply to all '?

    Thank you

    You can not interact with native applications except for adding your own menu entry (entries).

  • How to perform an action when the user clicks on the "OK" button on a script by xfa.host.response

    Hello

    I have a script that when you exit a field without the user data that a script response is mentioned.

    When the user has entered the required data in the dialog box and click the OK button I wish that the data user in the field as a value.

    Please can someone tell how this is possible?

    The script is listed as follows:

    If this field is stopped without the user to enter data, the following message is displayed

    If

    (Employee_ID.rawValue == null)

    {

    XFA. Host.Response ("is a required field, enter your employee id');

    }

    Hello

    I think that this script will do the job:

    If (this.rawValue is nothing)

    {

    var id = xfa.host.response ("is a required field, enter your employee id');
    this.rawValue = id;
    }

    Yan.

  • How oracle created by identification of the users and groups in the OID.

    Anyone know what LDAP search filters would give me only the OID users and groups created by the Oracle installation process itself?
    I want to write scripts to retrieve all users and groups that the developers have put in manually, as opposed to those created with installation or synchronized from the announcement.

    I tried things like ' (& (!)). (objectClass = orcladuser))) (& (objectclass = orcluserv2)(orclisenabled=ENABLED))) ' for users, but it's not quite restrictive. "

    Other ideas would be appreciated.

    Thank you!

    Published by: sherlihy on April 5, 2011 15:45

    There should be a date of creation. You could do a larger than the piece of timestamp in your query.

    -Kevin

  • How to classify with grouping

    Means I want top 5 records of each category. with the grouping, I would like to give rank in OBIEE. Please someone have any suggestions for it

    Pls try the following query:

    TOPN (GRADE (SALE by category), 5 per category)

  • How to perform account on a Table hierarchical Oracle based on the Parent link

    Hello


    I have the following to Oracle 11 g R2 hierarchical table definition:


    Table Name: TECH_VALUES:
      ID,
      GROUP_ID,
      LINK_ID
      PARENT_GROUP_ID,
      TECH_TYPE

    Above the hierarchical table definition, some examples of data might look like this:


    ID      GROUP_ID      LINK_ID      PARENT_GROUP_ID      TECH_TYPE 
    ------- ------------- ------------ -------------------- --------------
    1       100           LETTER_A     0
    2       200           LETTER_B     0
    3       300           LETTER_C     0
    4       400           LETTER_A1    100                  A 
    5       500           LETTER_A2    100                  A 
    6       600           LETTER_A3    100                  A 
    7       700           LETTER_AA1   400                  B 
    8       800           LETTER_AAA1  700                  C 
    9       900           LETTER_B2    200                  B 
    10      1000          LETTER_BB5   900                  B 
    12      1200          LETTER_CC1   300                  C
    13      1300          LETTER_CC2   300                  C
    14      1400          LETTER_CC3   300                  A
    15      1500          LETTER_CCC5  1400                 A
    16      1600          LETTER_CCC6  1500                 C
    17      1700          LETTER_BBB8  900                  B
    18      1800          LETTER_B     0
    19      1900          LETTER_B2    1800                 B 
    20      2000          LETTER_BB5   1900                 B 
    21      2100          LETTER_BBB8  1900
                     B


    Keeping in mind that there are only three Types of technology, i.e. A, B and C, but could not span on different LINK_IDs , how can I do a count on these three different TECH_TYPEs based solely on the ID of parent link where the parent group id is 0 and there are children below them?

    NOTE: It is also possible to have parents in dual link ID such as LETTER_B and all values of children but different group ID.

    I'm basically after a table/report query that looks like this:

    Link ID        Tech Type A         Tech Type B          Tech Type C
    -------------- ------------------- -------------------- -------------------
    LETTER_A      
    3                   1                    1
    LETTER_B      
    0                   3                    0
    LETTER_C      
    2                   0                    3
    LETTER_B      
    0                   3                    0

    Be hierarchical and my table can consist more of 30 000 files, I must also ensure that performance to produce the report above shown here query is fast.

    Obviously, in order to produce the report above, I need to gather all necessary County outages based on TECH_TYPE for all parents of the link id where the PARENT_GROUP_ID = 0 and store it in a table according to the guidelines of this report layout.

    Hope someone can help with maybe a combined query that performs the counties as well as stores the information in a new table called LINK_COUNTS, which will be based on this report. Columns of this table will be:

    ID,

    LINK_ID,

    TECH_TYPE_A,

    TECH_TYPE_B,

    TECH_TYPE_C

    At the end of this entire requirement, I want to be able to update the LINK_COUNTS table based on the results returned by the sample data above in a SQL UPDATE transaction as the link ID parent top-level already exists within my table LINK_COUNTS, just need to provide values for breaking County for each parent node link , i.e.

    LETTER_A

    LETTER_B

    LETTER_C

    LETTER_B

    using something like:

    UPDATE link_counts

    SET (TECH_TYPE_A,TECH_TYPE_B,TECH_TYPE_C) =

       (with xyz  where link_id = LINK_COUNTS.link_id .... etc

    Which must match exactly the above table/report

    Thank you.

    Tony.

    Hi, John,.

    Thanks for posting the sample data.

    John Spencer wrote:

    ...  If you need to hide the ID column, then you could simply encapsulate another external query around me. ...

    Or simply not display the id column:

    Select link_id, -id,

    Count (case when tech_type = 'A' end then 1) tech_a.

    Count (case when tech_type = 'B' then 1 end) tech_b,.

    Count (case when tech_type = "C" then 1 end) tech_c

    of (connect_by_root select link_id link_id,)

    the connect_by_root ID, tech_type

    of sample_data

    Start with parent_group_id = 0

    connect prior group_id = parent_group_id)

    Link_id group, id

    order by link_id, id;

    Same results, using SELECT... PIVOT

    WITH got_roots AS

    (

    SELECT CONNECT_BY_ROOT link_id AS link_id

    Id CONNECT_BY_ROOT ID

    tech_type

    OF sample_data

    START WITH parent_group_id = 0

    CONNECT BY PRIOR group_id = parent_group_id

    )

    SELECT link_id, tech_a, tech_b, tech_c

    OF got_roots

    PIVOT (COUNT (*)

    FOR tech_type IN ('A' AS tech_a

    'B' AS tech_b

    'C' AS tech_c

    )

    )

    Id ORDER BY link_id

    ;

  • How to deal with analysis PC Performance & Stability Report

    Yesterday, when I just walked into my Office Xp, an error report in a program called... uh, PC Performance & Stability Report analysis, can possibly be, telling me to correct these errors have shown under its professional service.
    How to deal with him?
    Thank you for your advice it.

    Hello MeriClaybron,

    1. have you installed any show analyzing the program on your computer?

    This problem can be caused due to infection by the Virus. I suggest that you run a virus scan on your computer using Microsoft Safety scanner and check if you have the same problem.

    http://www.Microsoft.com/security/scanner/en-us/default.aspx

  • an error "file does not have a program associated with it for performing this action" when you click office and recent places.

    Original title:

    Win7 victory explrer click dsktop & mployment plces & get eror msg file is not a CDSA wth to prfrmin ths field prgrm. pls instl one prgrm so is alrdy instld Credit Union assc ltvds cntrl pnl prgrms

    I don't know how to fix. Help, please.    Win7 windows Explorer click

    Office & recent locations & grterror msg:
    This file does not have a program associated with it for performing this action. Please install a program or, if it is already installed. create an asssociationin the default programs control panel.
     
    Information given in the new thread:
    Error Msg When you try open office spaces & recent since the win Explorer

    when im in windows Explorer and click on the desktop or the recent places the link I get a msg of error and they will not open, but all others open. I posted pictures of error msg to skydrive yesterday.

    Hello

    Welcome to the Microsoft Community Forums.

    I see you've found an error "file does not have a program associated with it for performing this action" when you click office and recent places.

    1. Have you made changes on the computer before this problem?
    2. What is the full error message?

    I suggest you to report to us the screenshot of the Advanced window so that we can understand what exactly the situation.

    See:
    Use SkyDrive download collected files and post screen shot/image
    http://social.technet.Microsoft.com/forums/en-us/w7itproui/thread/4fc10639-02dB-4665-993a-08d865088d65

    The average while you can try the following steps and check if the error reappears.

    Method 1:

    Step 1:

    Start the computer in safe mode and check the number.

    Some options, including the mode safe mode, start Windows in a limited State, where only the essential is started. If a problem doesn't reappear when you start in safe mode, you can eliminate the default settings and basic device drivers and services as a possible cause.

    Follow this link provided below to start your computer in safe mode.

    http://Windows.Microsoft.com/en-us/Windows7/advanced-startup-options-including-safe-mode

    Step 2:

    Put the computer to boot and check if the problem persists.

    To help resolve the error and other messages, you can start Windows 7 by using a minimal set of drivers and startup programs. This type of boot is known as a "clean boot". A clean boot helps eliminate software conflicts.

    How to troubleshoot a problem by performing a clean boot in Windows Vista or in Windows 7
    http://support.Microsoft.com/kb/929135

    Note: After troubleshooting, be sure to set the computer to start as usual as mentioned in step 3 of the KB article provided above.

    Method 2: I also suggest that you scan your computer with the Microsoft Security Scanner, which would help us to get rid of viruses, spyware and other malicious software.

    The Microsoft Security Scanner is a downloadable security tool for free which allows analysis at the application and helps remove viruses, spyware and other malware. It works with your current antivirus software.

    http://www.Microsoft.com/security/scanner/en-us/default.aspx

    Note: The Microsoft Safety Scanner ends 10 days after being downloaded. To restart a scan with the latest definitions of anti-malware, download and run the Microsoft Safety Scanner again.

    Important: During the scan of the hard drive if bad sectors are found, the scanner tries to repair this sector, all available on which data may be lost.

    It will be useful.

    Back with the details so that we can help you further. We also indicate the result of the suggested steps.

  • How Oracle Clusterware Oracle RAC and 3rd-party Clustering with them

    I have some questions on how Oracle, Oracle RAC and 3rd party clustering CLusterware fit between them.

    Q1. My understanding is that the Infrastructure Grid Oracle Clusterware is Oracle's Clustering solution that allows applications to cluster? that is, it is a general clusterware solution to compete with those already on the market. Is this correct?

    Q2. So why CARS is necessary for the Oracle cluster databases? An Oracle database is not just considered one application like any other? So why can not just use you GI / Clusterware to gather what you would do for any other application? Why so you need RAC to the Clusterware Summit?

    Q3. Is it is possible to combine an Oracle database using 3rd party of clustering and not use Oracle Clusterware and CARS at all that is can you say cluster, an Oracle database using say Sun Clusters, Clustering AIX or Linux native same clustering?

    Q4. If the RAC is purely for Oracle Cluster databases - what is with the title "Real Application Clusters"? What's real on this subject?, what to ask?

    Q5. I also read that RAC can use 3rd party of clustering. However if you decide that this is the case, then you need to install Oracle Clusterware when even (I think for interconnection must be created to allow the merger with Cache between Instances of node?).

    Is this the case?  If yes why never bore you with 3rd party clusters? -Since you will have to install Oracle Clustering anyway - and I probably have to license (all I can think about is the scenario that you already have a cluster of 3rd party in place and you decide that you need to use the same material for a database cluster)?

    All wisdom greatly appreciated,

    Jim

    Yes, with 10g, you had to use the CRS, and with 11g, to use the GI.  For 9i RAC, you would use Verits Cluster and Sun Cluster or anything else.

    11g RAC to GI.  As above, you can use clusterware extra if needed.  I gave the example above where to a 10g RAC we used the CRS to the cluster database/listener/vip and allowing groups of volume and filesystem in HACMP cluster.  File systems were not shared, but could switch to another node failure node, who has been treated by HACMP.  The volume of the groups containing the raw devices were shared volume groups.  For 11g, I never used extra clusterware on top of CRS and have always used ASM which is part of the GI.

    The application provider only certified database to run on 10g on AIX with raw devices.  What is strange about that?  It would be unusual that you probably expect to use ASM instead of raw devices, but it is what it is.

    See the following Note of Oracle for more information: using Oracle Clusterware with vendor Clusterware FAQ (Doc ID 332257.1)

    It is perhaps easier to explain if you can explain what problem you are trying to solve?

  • How oracle to count the number of users of Hyperion

    Hello

    Can I find out how Oracle count of users for Hyperion Planning? I disabled some dummy accounts in the Production environment, but they exist the planning app security group. Will be what they considered authorized users?

    Thank you

    As I see it is provisioned to users who could potentially access the system, so I assumed that disabled accounts could not access to the system so don't are not counted, just my opinion, I do not speak for Oracle

    As suggested, it always better to speak to the representative of account for any clarification.

  • How to suggest a new symbol of certification: (as OCP *), which includes certified more than professional oracle performance and tuning?

    Hello

    There are several versions Oracle has removed the requirement of performance and tuning in what concerns OCP.

    You can get a separate ECO - Oracle Certified Expert for the performance and tuning.

    However, databases there include performance and tuning in the basic DBA certification.

    I understand there is an OCP (for DBA) and a separate OCÉ (performance and tuning),

    but could it be considered as an additional symbol combining the OCP and OCE (such as OCP * or OCPE or OCP2).

    We could always get and OCP for DBA and a separate ECA for the performance and tuning.

    If there was an an additional symbol, then maybe selftest software would also create reviews of preparation for the performance and tuning.

    Perhaps more people write books on their performance and tuning of certification.

    Maybe Oracle would provide Web seminar Exam Prep for the performance and tuning.

    Thank you Roger


    If there was an an additional symbol, then maybe selftest software would also create reviews of preparation for the performance and tuning.

    Perhaps more people write books on their performance and tuning of certification.

    That hangs high hopes on a couple of letters.  The problem, however, is not perception, but the economy. Traditional publishers must sell a lot of books to make return on investment in the costs of creating a new. Until they beat X-thousand books, they are in the red. STS and transcend do not have publication costs, but they still have to pay someone (probably a very expensive one) to go through the mind-numbing task of creating a bunch of questions / answers that are enough like the real exam to be useful, but different enough to not be do not cheat. They should sell enough copies of the review of the practice of paying for that person, and then more overhead before making a profit.

    The main reason that I was able to create guides to study at the best prices is because they are printed on demand.  I don't have to recover the costs of printing a large number of copies in the hope they will sell. In addition, as I do all of the writing to editing to marketing of myself - it has no salaries to pay someone else. Despite this - I could easily do more initial money by running Oracle contract/work councils for the same number of hours that I put in my books and practice tests. I was called to joke with my wife I could do more by night shifts working underground, asking people if they want fries with that.

    The problem with an author or an editor of creating a book especially for an Oracle performance certification (say 1Z0-064 or 1Z0-117), is that there is so much work involved in this than the creation of a book of generic performance Oracle or Oracle SQL Tuning book, but the very act of this direct to the test severely limits the people who can buy it. Those who study for 1Z0 - 064 could well but a generic performance Oracle 12 c book.  However, people in the market for a book of performance 12 c but * not * intended to take certification 064 are not likely to buy this book even though she 1Z0 - 064 on the lid.

    There are not many hug of people with the knowledge and the ability to create these materials. This relatively small pool, it is there not much with the desire to do. This further reduced pool, there not much time for her - or at least of time they are willing to take more lucrative projects requiring their skills.

  • Hello, I bought a monthly license paid for indesign last night and I do not understand how to play with it? When I opened the window of creative cloud, they suggested me to buy indesign (but I bought it already...) Please, help me... It's easy to al amend

    Hello, I bought a monthly license paid for indesign last night and I do not understand how to play with it? When I opened the window of creative cloud, they suggested me to buy indesign (but I bought it already...) Please, help me... This is our easy to understand for beginners like me at all

    FAQ: What should I do if I have a subscription, but my application acts as if I had a trial?

    https://forums.Adobe.com/thread/1962238

    Download/install the desktop application, connect and install applications subscription.

    https://helpx.Adobe.com/creative-cloud/help/download-install-app.html

    Creative cloud to desktop

    https://helpx.Adobe.com/creative-cloud/help/creative-cloud-desktop.html

    Sign out, sign in | Creative office cloud app

    http://helpx.Adobe.com/creative-cloud/KB/sign-in-out-creative-cloud-desktop-app.html

    Install, update, or uninstall applications

    http://helpx.Adobe.com/creative-cloud/help/install-apps.html

  • I downloaded and installed the XI and when open wants to buy DC and enter again which gives the serial number and the error.  Does anyone know how to talk with Adobe cat

    I downloaded and installed the XI and when open wants to buy DC and enter again which gives the serial number and the error.  Does anyone know how to talk with Adobe cat

    Hey Kevin,

    It seems that you are getting the update to install Acrobat DC. This is the latest version of Acrobat.

    If you get an error message, could you please share the screenshot of the same so that we can check at our end.

    If you want to contact Adobe support team, see the following link to get in touch with them.

    http://helpx.Adobe.com/x-productkb/global/service-CCM.html

    http://helpx.Adobe.com/x-productkb/global/Service1.html

    Concerning

    Sukrit diallo

Maybe you are looking for

  • Tecra R10 - 10W - CMOS battery error and the next mistake of bios password

    I have some old Tecra R10 - 10W Aftert long in the cupboard, it says CMOS battery error and after charging I can't start on the old password (bios) system. How to reset the password of the bios and is also required for cmos battery and I can do it my

  • Slatebook 14 to 96%, after having been extinguished overnight.

    Hi once more: I just got my Slatebook 14 two days ago. Runs like a top and I LOVE IT! But I have a question. As I asked in my topic, this normal is 96-98% after being shutdown for a night? She goes to a FULL LOAD after 10 or 15 minutes. I had a table

  • Cannot access Web sites

    I often get redirected to another site when I try to access the websites and he prays me click on elements of research. How can I fix?

  • How can I print a list of the display of the contents of a specific MAIL folder?

    I have windows xp3 and use outlook express 6 - I want to be able to print the contents of a specific folder by e-mail... JUST A LIST OF THAT IS in THE FOLDER... .not the entire summary folder... not a real impression each email... e. g by clicking on

  • Epic fail to open a SOS file

    Every time I try to open a specific file on the internet it is for me and the error message that says: "the paint cannot read this file. It is not a valid bitmapfile, or its format is not currently supported. I try to open the file is a file in publi