Group By / Count

Post Author: Glux
CA Forum: WebIntelligence Reporting
Hi to everyone,
I'm starting to use BI XI and find it very interesting. However it is quite tricky to find info or how to adapt my own logic to it ;).
Well, hereinafter what I have. A table showing for each customer if they have the service (1) or not (empty)
Service 1
Service 2
Service 3
Customer 1
1
1
1
Customer 2
1
0
1
Customer 3
0
1
0
Customer 4
1
1
1
Customer 5
0
0
1
Customer 6
0
1
0
And what I want to have. A table that summaries how many customers have the same combination of services 
Service 1
Service 2
Service 3
Number of customers having this set of services
1
1
1
2
1
0
1
1
0
1
0
1
0
0
1
1
0
1
0
1
And I really don't find how to do it. Except exporting my individual data to Excell and doing a "subtotal".
Thanks for your help.
Regards.

Post Author: PrabhatKumar
CA Forum: WebIntelligence Reporting
Define one variable saying "Service Number" as =[Service1]""[Service2]""[Service3]+"" .
It will be a dimension, then make one new table and select only "Service Number" and add one mare column as =Count([Service Number])
Service 1
Service 2
Service 3
Service Number
Customer 1
1
1
1
111
Customer 2
1
0
1
101
Customer 3
0
1
0
010
Customer 4
1
1
1
111
Customer 5
0
0
1
001
Customer 6
0
1
0
010
This will give you below results:-
Service Number
Count
111
2
101
1
010
1
001
1
010
1
Let me know if it helps......
Prabhat

Similar Messages

  • Group and count

    Hello Friends,
    I have a query where I select organization, item_num, and transaction_date.
    I need to group and count the result by transaction_date, so I will have 3 groups:
    First - will count records where transaction_date falls between the 1st and 10th of the month.
    Second - will count records where transaction_date falls between the 11th and 20th of the month.
    Third - will count records where transaction_date falls between the 21st and 31st of the month.
    The result of this count will be used in the Oracle Report.
    Please, give me your advise on how I can achive this.
    Thank you.

    select organization,
           item_num,
           count(case
                   when transaction_date between trunc(transaction_date, 'mm') and trunc(transaction_date, 'mm') + 9 then 1
                 end) "1-10",
           count(case
                   when transaction_date between trunc(transaction_date, 'mm') + 10 and trunc(transaction_date, 'mm') + 19 then 1
                 end) "11-20",
           count(case
                   when transaction_date between trunc(transaction_date, 'mm') + 20 and trunc(last_day(sysdate)) then 1
                 end) "21-end"
      from mytable
    group by organization, item_num
    Ramin Hashimzade

  • How To Use QoQ For Group By Count

    Ok, I am having a issue with Group By and Count.  Basically, here is what i am working with...
    <cfquery name="TEST" datasource="MyDataSource">
         SELECT
              ContentID, ContentName, ProductID
         FROM
              MyTable
    </cfquery>
    HERE IS AN EXAMPLE DUMP
    1, ABCD, 33
    1, ABCD, 34
    1, ABCD, 35
    1, ABCD, 36
    1, ABCD, 37
    2, EFG, 342
    2, EFG, 343
    2, EFG, 344
    2, EFG, 345
    2, EFG, 346
    2, EFG, 347
    2, EFG, 348
    3, HIJK, 101
    3, HIJK, 102
    3, HIJK, 103
    Then I run this query on it.
    <cfquery name="MYGROUPLIS" dbtype="query">
          SELECT
              ContentID, ContentName, COUNT(ProductID)
          FROM
              TEST
         GROUP BY
              ContentID, ContentName
    </cfquery>
    It Should be this:
    1, ABCD, 5
    2, EFG, 7
    3, HIJK, 3
    But instead i get this:
    1, ABCD, 12
    1, EFJ, 12
    1, HIJK, 12
    WHY?????

    I refactored your example code to be stand-alone, and ran it.
    Here's the code:
    <cfscript>
        qTest = queryNew("contentId,contentName,ProductID", "Integer,Varchar,Integer");
        queryAddRow(qTest); querySetCell(qTest, "contentId", 1); querySetCell(qTest, "contentName", "ABCD"); querySetCell(qTest, "ProductID", 33);
        queryAddRow(qTest); querySetCell(qTest, "contentId", 1); querySetCell(qTest, "contentName", "ABCD"); querySetCell(qTest, "ProductID", 34);
        queryAddRow(qTest); querySetCell(qTest, "contentId", 1); querySetCell(qTest, "contentName", "ABCD"); querySetCell(qTest, "ProductID", 35);
        queryAddRow(qTest); querySetCell(qTest, "contentId", 1); querySetCell(qTest, "contentName", "ABCD"); querySetCell(qTest, "ProductID", 36);
        queryAddRow(qTest); querySetCell(qTest, "contentId", 1); querySetCell(qTest, "contentName", "ABCD"); querySetCell(qTest, "ProductID", 37);
        queryAddRow(qTest); querySetCell(qTest, "contentId", 2); querySetCell(qTest, "contentName", "EFG"); querySetCell(qTest, "ProductID", 342);
        queryAddRow(qTest); querySetCell(qTest, "contentId", 2); querySetCell(qTest, "contentName", "EFG"); querySetCell(qTest, "ProductID", 343);
        queryAddRow(qTest); querySetCell(qTest, "contentId", 2); querySetCell(qTest, "contentName", "EFG"); querySetCell(qTest, "ProductID", 344);
        queryAddRow(qTest); querySetCell(qTest, "contentId", 2); querySetCell(qTest, "contentName", "EFG"); querySetCell(qTest, "ProductID", 345);
        queryAddRow(qTest); querySetCell(qTest, "contentId", 2); querySetCell(qTest, "contentName", "EFG"); querySetCell(qTest, "ProductID", 346);
        queryAddRow(qTest); querySetCell(qTest, "contentId", 2); querySetCell(qTest, "contentName", "EFG"); querySetCell(qTest, "ProductID", 347);
        queryAddRow(qTest); querySetCell(qTest, "contentId", 2); querySetCell(qTest, "contentName", "EFG"); querySetCell(qTest, "ProductID", 348);
        queryAddRow(qTest); querySetCell(qTest, "contentId", 3); querySetCell(qTest, "contentName", "HIJK"); querySetCell(qTest, "ProductID", 101);
        queryAddRow(qTest); querySetCell(qTest, "contentId", 3); querySetCell(qTest, "contentName", "HIJK"); querySetCell(qTest, "ProductID", 102);
        queryAddRow(qTest); querySetCell(qTest, "contentId", 3); querySetCell(qTest, "contentName", "HIJK"); querySetCell(qTest, "ProductID", 103);
    </cfscript>
    <cfquery name="qGrouped" dbtype="query">
        SELECT        contentId, contentName, COUNT(ProductID)
        FROM        qTest
        GROUP BY    contentId, contentName
    </cfquery>
    <cfdump var="#qGrouped#">
    Here's the result:
    COLUMN_2
    CONTENTID
    CONTENTNAME
    1
    5
    1
    ABCD
    2
    7
    2
    EFG
    3
    3
    3
    HIJK
    Which is what of us expect.
    What version of CF are you on?  I'm running this on CF8.0.1
    Are you certain about the data coming back from the DB?
    Adam

  • Group and count by range of amount

    Hi all,
    I have a list of 400,000 lines like this:
    But I need grouped by amount of 10 and count the number of clients grouped, something like this:
    I hope the pictures explain better my problem.
    Thanks for your support
    Carlos

    Hi Carlos,
    According to your description, this issue is more related to excel instead of excel development.
    The Excel IT Pro Discussions forum is the better place for excel questions, we will move it there for you.
    Regards
    Starain
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Group by count distinct

    mytable
    id | yy
    1 | 78
    2 | 78
    3 | 78
    3 | 79
    3 | 79
    4 | 79
    5 | 79
    5 | 80
    Desired output:
    yy | id_count
    78 | 3
    79 | 2
    80 | 0
    Following query doesn't work, as it doesn't take into account that id was already counted
    select yy, count(distinct id) as id_count
    from mytable
    group by yy
    --output
    yy | id_count
    78 | 3
    79 | 4
    80 | 1
    Hope this makes sense.
    Ideas?

    Hi,
    You only want to count each id once, with the first (that is, lowest) yy: is that right?
    Here's one way:
    WITH     got_r_num    AS
         SELECT  id
         ,     yy
         ,     ROW_NUMBER () OVER ( PARTITION BY  id
                                   ORDER BY          yy
                           ) AS r_num
         FROM    my_table
    SELECT       yy
           COUNT ( CASE
                      WHEN  r_num = 1
                    THEN  id
                  END
              )     AS id_cnt
    FROM       got_r_num
    GROUP BY  yy
    ORDER BY  yy
    ;Doing anything for the first of each id is probably a job for "ROW_NUMBER () OVER (PARTITION BY id ...)".

  • Need Help with an Group By Count

    I'm having some difficulties with a query.
    My results are as follows:
    Acct_num - Route_ID - Service
    12345678 - 1112222 - Gas -
    12345678 - 1112222 - H20 -
    12345678 - 3334444 - Elec -
    98765432 - 8889999 - Gas -
    98765432 - 8889999 - H20 -
    98765432 - 8889999 - Elec -
    What i need to do is write a script that will show me, any acct_num's where the route_id is different. All Route_id's should be the same for all services, but in some cases, they were entered incorrectly and i need to find the invalid ones, so i can correct them.
    Ideally, i would only like to see one row, but if i can just get my results to show me all the acct_num for the ones where the route_id is different, that would be a great start
    I have been trying to use a distinct and do a count on the acct_num, but my counts are ignoring the distinct.
    This is the code i have been using so far, but i don't think it is on the right path:
    SELECT distinct SA.SERVICE_ACCOUNT_NUMBER,
           MR.METER_ROUTE_ID,
    --       ECAT.SERVICE_TYPE--,
           count(SA.SERVICE_ACCOUNT_NUMBER) as ACCT_NUM_COUNT
    FROM SERVICE_ADDRESS SADD,
         SERVICE_ACCOUNT SA,
         SERVICE_SERVICE_ACCOUNT SSA,
         EQUIPMENT E,
         EQUIPMENT_CLASS EC,
         EQUIPMENT_CATEGORY ECAT,
         EQUIPMENT_LOCATION EL,
         EQUIPMENT_LOCATION_EQUIP ELE,
         EQUIPMENT_LOCATION_ROUTE ELR,   
         EQUIPMENT_TYPE ET,
         METER_ROUTE MR       
    WHERE SADD.SERVICE_ADDRESS_ID = SA.SERVICE_ADDRESS_ID
    AND SSA.SERVICE_ACCOUNT_NUMBER = SA.SERVICE_ACCOUNT_NUMBER
    AND SSA.END_DATE IS NULL                             
    AND SSA.SERVICE_ID = E.CURRENT_SERVICE_ID
    AND ET.EQUIPMENT_CLASS = EC.EQUIPMENT_CLASS
    AND EC.EQUIPMENT_CATEGORY = ECAT.EQUIPMENT_CATEGORY
    AND EL.EQUIPMENT_LOCATION_ID = ELR.EQUIPMENT_LOCATION_ID
    AND EL.EQUIPMENT_LOCATION_ID = ELE.EQUIPMENT_LOCATION_ID
    AND ELE.EQUIPMENT_ID = E.EQUIPMENT_ID
    AND E.EQUIPMENT_TYPE_ID = ET.EQUIPMENT_TYPE_ID
    AND EC.EQUIPMENT_CATEGORY LIKE '%METER'
    AND ELE.END_DATE IS NULL
    AND MR.METER_ROUTE_ID = ELR.METER_ROUTE_ID
    AND SA.SERVICE_ACCOUNT_NUMBER IN (6051, 124899)
    GROUP BY SA.SERVICE_ACCOUNT_NUMBER, MR.METER_ROUTE_ID
    --HAVING COUNT(sa.service_account_number) > 1thanks in advance

    If you take your query more or less as it is:
    select <code> SA.SERVICE_ACCOUNT_NUMBER,MR.METER_ROUTE_ID</code>
    FROM (rest of your query) take your query more or less as it is:
    select <code> SA.SERVICE_ACCOUNT_NUMBER,MR.METER_ROUTE_ID</code>
    FROM (rest of your query) and then wrap around it:
    select <code>SERVICE_ACCOUNT_NUMBER</code>,count(*)
    from (your query above)
    GROUP BY saervice_account_number
    having count(*) &gt; 1
    that should give you what you want.
    The inner query gives you all of the account#/route combinations.
    The outer query picks those account#s with more than one route.
    Jon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • GROUP BY+COUNT+SUM SQL

    Hi,
    I have a table, it has 2 colunms, ( name,number)
    name number
    B1 7
    B1 7
    B1 28
    B1 28
    B1 28
    B2 7
    B2 28
    B3 7
    I want to see below
    number
    name sum 7sum 28sum
    B1 5 2 3
    B2 2 1 1
    B3 . . .
    CAN YOU HELP ME
    THANK YOU VERY MUCH FOR HELP

    Like this?
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select 'B1' as name, 7 as num from dual union all
      2             select 'B1', 7 from dual union all
      3             select 'B1', 28 from dual union all
      4             select 'B1', 28 from dual union all
      5             select 'B1', 28 from dual union all
      6             select 'B2', 7 from dual union all
      7             select 'B2', 28 from dual union all
      8             select 'B3', 7 from dual)
      9  --
    10  -- end of test data - use query below
    11  --
    12  select name
    13        ,count(*)
    14        ,sum(decode(num,7,1,0)) as sum7
    15        ,sum(decode(num,28,1,0)) as sum28
    16  from t
    17  group by name
    18* order by 1
    SQL> /
    NA   COUNT(*)       SUM7      SUM28
    B1          5          2          3
    B2          2          1          1
    B3          1          1          0

  • Select, grouping and counting...

    Hi again, I managed to bypass my trigger problem, so thanks a lot...!
    Now, I have a simple question...
    Using two tables, Joueur (NoJ (PK), NoE(PK, FK1), NomJ, Adresse, Tel, CoJ)
    and Equipe (NoE(PK,FK1), NomE, NoJC(Fk1 of NoJ))
    I'll explain the model...
    It's a Team table, and a Player Table.
    Naturally, the PK on Player (Joueur) is NoE (team number) and NoJ (Player number)
    On the Team table, the primary key is NoE (Team number
    and the foreign key is NoE AND NoJC which stands for the number of the CAPTAIN player ...
    So...
    I've got to make a table of 4 cloumns: Team number (NoE), Team name (NomE), Team captain name, number of player in team...
    So I need to combine those two tables... on the first table, I got all the info BUT the number of players, which lists all 1 due to the where NoJC = NoJ... but this function is required to get the Captain name...
    Select NoE, NomE, NomJ as Capitaine, count(*)
    from EQUIPE join JOUEUR using (NoE)
    where NoJ=NoJC
    group by NoE, NomE, NomJ;
    select noe, count(*)
    from EQUIPE join JOUEUR using (NoE)
    group by noe;Any clue?

    I suggest for you :
    Put then column noJC in joueur table nojc NUMBER CONSTRAINT fk_no_joueur_cap REFERENCES joueur(noj);
    Regards Salim.
    SQL> DROP TABLE joueur;
    Table supprimée.
    SQL> DROP TABLE equipe;
    Table supprimée.
    SQL> CREATE TABLE equipe (noe NUMBER CONSTRAINT pk_no_eq PRIMARY KEY, nome VARCHAR2(30));
    Table créée.
    SQL> CREATE TABLE joueur (noj NUMBER CONSTRAINT pk_no_joeur PRIMARY KEY,
      2                       noe NUMBER CONSTRAINT fk_no_equipe REFERENCES equipe(noe),
      3                       nomj VARCHAR2(30), adresse VARCHAR2(100), tel VARCHAR2(20),
      4                       coj VARCHAR2(10), nojc NUMBER CONSTRAINT fk_no_joueur_cap REFERENCES joueu
    r(noj) );
    Table créée.
    SQL> INSERT INTO equipe
      2       VALUES (1, 'RC Kouba');
    1 ligne créée.
    SQL> INSERT INTO joueur
      2       VALUES (1, 1, 'Salim', '... Montreal', '514-111-1111', 'NNN', NULL);
    1 ligne créée.
    SQL> INSERT INTO joueur
      2       VALUES (2, 1, 'Richard', '... Montreal', '514-111-2222', 'NNN', 1);
    1 ligne créée.
    SQL> INSERT INTO joueur
      2       VALUES (3, 1, 'Stéphane', '... Montreal', '514-111-3333', 'NNN', 1);
    1 ligne créée.
    SQL> COMMIT ;
    Validation effectuée.
    SQL>
    SQL> SELECT   equipe.noe, equipe.nome, j.noj nojc, j.nomj capitaine,
      2           COUNT (joueur.noj) AS "Nombre de joueurs"
      3      FROM joueur, equipe, joueur j
      4     WHERE joueur.noe = equipe.noe AND j.noe = equipe.noe AND j.nojc IS NULL
      5  GROUP BY equipe.noe, nome, j.noj, j.nomj;
           NOE NOME                                 NOJC CAPITAINE                      Nombre de joueurs
             1 RC Kouba                                1 Salim                                          3
    SQL>

  • Grouping and Counting

    I have a table of member_id's and number codes and dates. Each member can have any number of any of the available codes allocated to him on different dates. I need to be able to be able to group by member_id and count the number of a specified code allocated to each member. I need to show zero counts. Does that make sense?
    Any help with this would be greatly appreciated
    Lindsay

    lindsay wrote:
    I have a table of member_id's and number codes and dates. Each member can have any number of any of the available codes allocated to him on different dates. I need to be able to be able to group by member_id and count the number of a specified code allocated to each member. I need to show zero counts. Does that make sense?Not really. When you have a problem you'll get a faster, more effective response by including as much relevant information as possible upfront. This should include:
    <li>Full APEX version
    <li>Full DB/version/edition/host OS
    <li>Web server architecture (EPG, OHS or APEX listener/host OS)
    <li>Browser(s) and version(s) used
    <li>Theme
    <li>Template(s)
    <li>Region/item type(s)
    With APEX we're also fortunate to have a great resource in apex.oracle.com where we can reproduce and share problems. Reproducing things there is the best way to troubleshoot most issues, especially those relating to layout and visual formatting. If you expect a detailed answer then it's appropriate for you to take on a significant part of the effort by getting as far as possible with an example of the problem on apex.oracle.com before asking for assistance with specific issues, which we can then see at first hand.
    Where exactly does APEX come into this? It sounds more like a general SQL problem which might be better suited to the {forum:id=75} forum.
    Either here or there, Re: 2. How do I ask a question on the forums? would make the problem clearer than any amount of vague description. Post this code wrapped in <tt>\...\</tt> tags.

  • Multiple Page Counts / Group Page Count

    I'm trying to have a page count per group on my reports.
    For example, we have a report that prints a Move Order. A Move Order may have multiple pick slips (one per sub-inventory). I want to have a Move Order page count and a Pick Slip page count.
    Does anybody have a way to do this?
    Thanks,

    You aren't really linking the frames to the pages. Simply set the "page break before" on the second frame. When the first frame finishes printing (regardless of how many pages that is) it will skip to the next page before the second frame starts printing. If required, you can make the page numbering re-set if you want to based on repeating frame values.
    If you really want to distinguish between the layouts, you can create up to 3 layouts by using each of the three sections (header, main, trailer). As each section finishes, there is also a page break before the next section starts.
    You can get at the page number using srw.get_page_num() but I don't think this will help you.

  • All Users and User Groups member count 0

    I've setup SCCM 2012 R2, configured the AD User Discovery. But my Member count for All Users and User groups is 0, Memebers Visible on Site is 968. 
    I'm not sure how to get the Member count working. 

    Hi,
    Please check Smsprov.log to see whether there are any errors when you open Device Collections.
    Best Regards,
    Joyce
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • GMail, Google Groups & Unread Count System

    Hi folks. I have some things about the mail.app that are not working as I expect them to.
    I have a gmail account that's read using the mail.app, as it's an IMAP account. I have some Google Groups that post to this account several times a day.
    I have a smart list in mail.app that notifies me of any unread items in my gmail account. I read them as they come in, but the unread count stays in my GMail IMAP account down below. Also, since it's in my "Important" smart mailbox on GMail, it's in there as well. So any incoming emails from that group shows up three times. I want to read it once and have it be shown as read in my account and smart mailbox on GMail.
    How can I set this up?
    Cheers

    I had the same problem and was able to find a workaround. The key insight actually came from another one of your (jkwuc89) posts where you mentioned:
    Loading GMail or Google Reader from a Safari bookmark appears to behave differently when compared to loading either site from a link on another page.
    The solution is to change the address of your bookmark so that it is similar to loading the site from a link on another page. When you bookmark Gmail, it's address will read:
    https://mail.google.com/mail/#inbox
    However, edit the address of this bookmark to:
    javascript:window.location='https://mail.google.com/mail/#inbox'
    This Javascript snippet will trick Safari to open Gmail as if you had clicked a link on another page and the tab will display the correct page title including unread count. You can follow a similar pattern with Google Reader or other sites that exhibit a similar problem.

  • Group by count in xml

    Hi
    I have a xml file like this
    G1
    Col1
    Col2
    G2
    Type name1 tag
    Type name 2. Tag
    G3
    Count tag for type name1
    Several tags for type name1
    Count tag for type name 2
    Several tags for type name2
    G3 end
    G2 end
    G1
    How to calculate tge sum of all counts according to the type name 1 or 2
    ...like. type1: count10
    Type 2:count 5
    Please help
    Thanks
    Kp

    Hi BIPUser
    Thanks a lot for your time..But it did not work...I pasted the exact thing..Can you please review and let me know..
    Trying to find the exact no of days for 'BLUE' Type..Another type is RED..but not yet got data for that..
    <?xml version="1.0" encoding="UTF-8"?>
    <A1>
    <Q1>
    <Invoice_Type>BLUE</Invoice_Type>
    <tag2>150</tag1>
    <tag3>1234</tag2>
    <tag4>2567</tag3>
    <Q2>
    <textattribute5>10000001</textattribute5>
    <invoice_type>BLUE</invoice_type>
    <Q4>
    <Hold_Release_days>132.95</Hold_Release_days>
    <Q4_Invoice_id>10000001</Q4_Invoice_id>
    </Q4>
    </Q2>
    <Q2>
    <textattribute5>200001</textattribute5>
    <invoice_type>BLUE</invoice_type>
    <Q4>
    <Hold_Release_days>2.99</Hold_Release_days>
    <Q4_Invoice_id>200001</Q4_Invoice_id>
    </Q4>
    </Q2>
    </Q1>
    <Q1>
    <Invoice_Type>RED</Invoice_Type>
    <tag2>61</tag2>
    <tag3>222</tag3>
    <tag4>400</tag4>
    <Q2>
    <textattribute5>10000002</textattribute5></Q1>
    <invoice_type>RED</invoice_type></A1>
    <Q4>
    <Hold_Release_days>152.95</Hold_Release_days>
    <Q4_Invoice_id>10000002</Q4_Invoice_id>
    </Q4>
    </Q2>
    <Q2>
    <textattribute5>200002</textattribute5>
    <invoice_type>RED</invoice_type>
    <Q4>
    <Hold_Release_days>2.00</Hold_Release_days>
    <Q4_Invoice_id>200002</Q4_Invoice_id>
    </Q4>
    </Q2>
    </A1>
    thanks
    kp

  • Count(1) returns null in group by

    hi gems..good afternoon..
    I read that the COUNT() function always returns 0 (zero) if there is no matching rows in the table.
    The following code returns the 0 as expected:
    SELECT COUNT(1) FROM book_table
                 WHERE client_id = 10009
                   AND book_id = 5465465
                   AND book_sub_id = 'gfdf'
                   AND amount = 78686But when I used the GROUP BY clause with the query, then it returned nothing:
    SELECT COUNT(1) FROM book_table
                 WHERE client_id = 10009
                   AND book_id = 5465465
                   AND book_sub_id = 'gfdf'
                   AND amount = 78686
    group by client_id,book_id,book_sub_id,amountWhy this is happening..please suggest...

    gogol wrote:
    But Ranit...
    Again I am thinking...the COUNT() is an aggregate function. Now a function should return something(as per my plsql knowledge) and in this case the return datatype is integer. So why isnt it returning zero..Don't think like that sandy.
    The Group By is actually done on an empty result set, so the result is neither 0 nor NULL
    It is an empty result set.
    Check this -- http://stackoverflow.com/questions/2552086/does-count-always-return-a-result
    >
    The "return value of the 'count' function" is ALWAYS a non-null integer, without exception. By mentioning "group by", you're referencing the containing query and changing the subject of "return value" from "count function" to "query's result set". A non-grouped count query produces a result set of a single record containing the return value of count. Alternatively, a grouped count query produces a result set where each record contains a count value. In that case, if there are no groups for count to run on, count is never run and the "query return value" is an empty set.
    >
    Hope this Helps.
    Ranit B.
    Edited by: ranit B on Nov 23, 2012 5:25 PM

  • Sql statement to get the count of items in a group.

    i have a table  as follows
    group id   items
       1            item1
       1            item2
       1            item3
       2            item4
       2            item5
    i need to get the count of items for each group
    the out put should be like
    group = 1 count = 3
    group = 2 count = 2
    i wrote the following query
    select   group count( * )
       into     (group , lv_count)
      from     table1
      group by group.
      endselect.
    is it possible to write this query without using end select.
    when i am using the same query with into table addition the count is not coming.

    Hi,
    It will work, I tested just now, ofcourse with some other table.
    Like this:
    select group count( * )
    INTO TABLE ITAB
    from table1
    group by group.
    Regards,
    Amit Mittal.

Maybe you are looking for

  • Purchase Price Variance Report - incorrect calculation

    Good afternoon all, As a relative new comer to Oracle I'm after some help/advice. When running a PPV report I'm not convinced the report is returning the correct answer. The report seems to be calculating the PPV as Qty x PO Price. It should be Qty x

  • Learn the number of pulses created in a finite pulse train

    Hello I am using the PCI-6602 Board to produce a finite number of pulses with counter0. I want to know how many pulses that are already created by the counter, while my program is running and show this number on an indicator on the front panel of my

  • I need two header line in table control

    Hi all, I am using table control. The requirement is to have 2 headers in the table control. for example., if their is field name ' Vendor Comments', I need to display 'Vendor' in one line and 'Comments' in next line. Is it possible to have such 2 he

  • How to lock targetserver execution in job scheduling

    Hi, I've a SAP System with a central instance and two application servers. I would set authorizations so that users when they schedule their jobs (example in SM37), the field target server is locked and set to a particular application server. Any ide

  • Iphone activation fail

    Hi all, I have bought an iphone from internet and I can't use it. The iphone can't be activated because it was registered with the account of the old owner. And the seller can't remove the iphone from is account because he lost his login. What i must