SUM of "SELECT originator, COUNT(*) as Inductions"

Hi,
I'm trying to SUM the results of "*SELECT originator, COUNT(*) as Inductions*" but am having trouble finding a solution?
Can this be done and cause it to create the SUM in a row below the created Inductions column?
Thanks in Advance.
James

955600 wrote:
Hi,
I'm trying to SUM the results of "*SELECT originator, COUNT(*) as Inductions*" but am having trouble finding a solution?
Can this be done and cause it to create the SUM in a row below the created Inductions column?
Thanks in Advance.
James
17:33:30 SQL> select deptno, sum(sal) from emp group by deptno;
    DEPTNO   SUM(SAL)
     30      9400
     20     18650
     10      8750
17:34:02 SQL> How do I ask a question on the forums?
SQL and PL/SQL FAQ

Similar Messages

  • The selected original image is either offline or not found. Please reconnect it and try again.

    Hi to all, This is my first time here. I am having a problem that I've never had before. I am attempting to upload images to Flickr, which I do daily without trouble. However, this time I'm getting the message: "The selected original image is either offline or not found. Please reconnect it and try again." I am doing searches on my MacBook by copying and pasting the jpeg name in to the finder and they seem to be gone. I have taken special care to file my photos in certain folders. Either I have inadvertanly deleted entire folders or something very odd has happened. Can anyone shed any light on this? Thank you

    Hi, Thank you for the response.
    I'm on 10.7.5 OS
    Ver. 3.4.3 Aperture
    I have a folder on my desktop named "photo imports" I insert my card to the reader on my MacBook Pro and copy the files in to a folder nested within the Photo imports according to which camera I am using or sometimes it is a special project. This folder is on my computer's hard drive. 
    I then go in to Aperture and click "Import" I select in the "Store Files" menu: "in their current location"
    This has been working nicely for me. I use Time Machine on a somewhat regular basis and I also use other editing software like Picassa and View NX2 (Nikon software)
    I suppose that it is possible that I accidently dragged my folder in to the trash, but I really do try to be careful about that sort of thing. I have gone back in to Time Machine and have been unable to find the files. It is vexing. My granddaughter has been asking me for those particular pictures and the only way to view them is in Aperture on my computer because I am unable to email or export them in any way.

  • Problem in selecting the count

    This the query which gives output as
    select substr(c.department_edesc,1,15)Department ,
         substr(a.employee_code,1,8)Code,
         substr(b.employee_edesc,1,20)Name ,
         SUBSTR(min(a.log_time),1,8) INTIEM,
         SUBSTR(max(a.log_time),1,8) OUTTIEM,
         substr(d.gate_edesc,1,9)Gate
         /* substr(e.company_edesc,1,15)Company */
         From hr_attendance_detail a, hr_Employee_setup b , hr_department_code c                ,hr_attendance_gate_code d , company_setup e
         where a.employee_code = b.Employee_code
         and a.company_code = b.Company_code
         and b.company_code = c.company_code
         and b.cur_department_code = c.department_code and a.attend_no in (select attend_no
    from hr_attendance where To_char (attend_date, 'DD-MON-YYYY') = '17-AUG-2004'
    and Company_code = a.company_code )
    GROUP BY c.department_edesc, a.employee_code, b.employee_edesc, d.gate_edesc,e.company_edesc
    DEPARTMENT CODE NAME INTIEM OUTTIEM GATE
    ADMIN DEPARTMEN 0000110 Ashok JB Singh 10:32:29 16:37:21 RECEPTION
    ADMIN DEPARTMEN 0000021 Sagar P. Upreti 09:53:24 09:53:24 RECEPTION
    ADMIN DEPARTMEN 0000024 Rajendra Giri 11:12:08 17:25:21 RECEPTION
    ADMIN DEPARTMEN 0000030 Ajab Bikram Bista 09:19:14 18:20:36 RECEPTION
    SALES DEPARTMEN 0000005 Prabhakar S. Thapa 09:25:50 17:46:17 RECEPTION
    SALES DEPARTMEN 0000006 Hemraj Bohara 09:11:36 16:42:50 RECEPTION
    SALES DEPARTMEN 0000007 Bishnu Raj Tripathi 09:53:27 16:32:49 RECEPTION
    SALES DEPARTMEN 0000008 Keshav Dhital 10:21:41 15:46:10 RECEPTION
    SALES DEPARTMEN 0000011 Rup Narayan Mahato 10:12:15 17:27:08 RECEPTION
    SALES DEPARTMEN 0000012 Mohan Dahal(Khatri) 09:13:39 17:50:06 RECEPTION
    SALES DEPARTMEN 0000013 Surya Brd. Lama 10:20:43 15:55:36 RECEPTION
    now I want to count the total no of in and out of each employee which is get from referance hr_attendance_detail table .
    Desc hr_attendance_detail
    Name Null? Type
    ATTEND_NO NOT NULL VARCHAR2(20)
    EMPLOYEE_CODE NOT NULL VARCHAR2(30)
    LOG_TIME NOT NULL VARCHAR2(8)
    LOG_MODE NOT NULL VARCHAR2(3)
    GATE_CODE NOT NULL VARCHAR2(2)
    MOVEMENT_CODE NOT NULL VARCHAR2(4)
    COMPANY_CODE NOT NULL VARCHAR2(30)
    BRANCH_CODE NOT NULL VARCHAR2(30)
    CREATED_BY NOT NULL VARCHAR2(30)
    CREATED_DATE NOT NULL DATE
    DELETED_FLAG CHAR(1)
    EREMARKS VARCHAR2(100)
    NREMARKS VARCHAR2(100)
    SYN_ROWID VARCHAR2(18)
    The movement_code which has value M001 and m003 for in and m002 and m004 for out.
    so plz add below sql query to the above first query so that I can use single query to select total in and total out.
    select count(movement_code) from hr_attendance_detail where movement_code like 'M001' || 'M003'; /*for total in*/
    select count(movement_code) from hr_attendance_detail where movement_code like 'M002' || 'M004';/*total Out*/

    Thank you Mr.Sadheesh Kumar Manavalan But it shows error as following and for your kind information I am using Oracle 8i
    SQL>
    1 Select AllDetails.*, in.Movement_count, out.Movement_count
    2 from
    3 (select substr(c.department_edesc,1,15)Department ,
    4 substr(a.employee_code,1,8)Code,
    5 substr(b.employee_edesc,1,20)Name ,
    6 SUBSTR(min(a.log_time),1,8) INTIEM,
    7 SUBSTR(max(a.log_time),1,8) OUTTIEM,
    8 substr(d.gate_edesc,1,9)Gate
    9 /* substr(e.company_edesc,1,15)Company */
    10 From hr_attendance_detail a, hr_Employee_setup b , hr_department_code c ,hr_attendance_gate_cod
    11 where a.employee_code = b.Employee_code
    12 and a.company_code = b.Company_code
    13 and b.company_code = c.company_code
    14 and b.cur_department_code = c.department_code and a.attend_no in (select attend_no
    15 from hr_attendance where To_char (attend_date, 'DD-MON-YYYY') = '17-AUG-2004'
    16 and Company_code = a.company_code )
    17 GROUP BY c.department_edesc, a.employee_code, b.employee_edesc, d.gate_edesc,e.company_edesc) A
    18 (select employee_code,count(movement_code) Movement_count
    19 from hr_attendance_detail where movement_code like 'M001' || 'M003' group by employee_code) IN,
    20 (select employee_code,count(movement_code) Movement_count
    21 from hr_attendance_detail where movement_code like 'M002' || 'M004' group by employee_code) OUT
    22* where Alldetails.employee_code=IN.employee_code and Alldetails.employee_code=Out.employee_code;
    SQL> /
    Select AllDetails.*, in.Movement_count, out.Movement_count
    ERROR at line 1:
    ORA-00936: missing expression

  • Select  and count from table

    Hi,
    I have table with  project end pernr and i wont to count how much
    employee  i have for  projects
    e.g.
    pernr        project
    123         e0-111
    565         e0-111
    158         e0-111
    145         e1-222
    456         e1-222
    665         e1-222
    222         e1-222
    222         e6-777
    i wont to get:
       e0-111 3
      e1-222  4
      e6-777  1
    What is the best way to do that ?
    Regards

    Keep you internal table like this way
    data : begin of itab occurs 0.
    data : project like zmytable-project.
    data : cnt   type i.
    data : end of itab.
    Select project count(*) as cnt
    from zmytable
    into table itab
    group by project.

  • All of a sudden all of my tracks are squeezed to the left. The Bar Ruler begins at "1" with the next measure at "129" on to the thosands. How do I get back to my original count and un-squeeze my tracks? thank you. John

    All of a sudden all of my tracks are squeezed to the left. The Bar Ruler begins at "1" ith the next measure at "129" on to the thosands. How do I get back to my original count and un-squeeze my tracks? thank you, John at [email protected]

    Welcome to Discussions - the fact that the S.M.A.R.T. status is not recognized and the flashing questions mark appear seem to indicate that your hard drive has failed. If you have access to TechToolPro or Disk Warrior, try to use them to check the drive status. This will likely not work, and I'm afraid your disk is toast.
    You could try to remove the drive and put it in an external case and try to mount it on your MacBook, but I don't hold out much hope for that either. You can try using [Data Rescue|http://www.versiontracker.com/dyn/moreinfo/macosx/211375] to retrieve your data.
    You can also take it in to Apple and see what they say. Please let us know how things turn out,

  • How to get the sum of selected check boxes?

    I have created this simple form with several fields. Fields can be selected via a check-box and they have a price listed.
    I would like to have the sum of each selected product, added in total.
    You can check it out here: https://www.dropbox.com/s/wl1bqz4fa0vlrsk/Student%20Form.pdf
    Help.. anyone?

    it's me again..
    here's a solution: http://forums.adobe.com/thread/929801

  • Can't select original library...

    I created a new library and now I can't open my other one. I hold shift when opening and go to choose library. Then when I select my original library, it gives me the option to open. This just keeps opening subfolders and I can't choose the library!! Please help!!

    Sure that will work, I understand. I'd like to click and make a menu selection not type. I guess using a Mac makes me lazy.
    I see when right-clicking there's an option to "Show In Finder," and I could delete from there, but it ought to be done from within iTunes of course.
    I'm just wondering if I'm overlooking something. Perhaps there's no way to do it through a menu, in which case, maybe this is a feature request for a future version of iTunes.

  • Select a count using the last entry of a table

    I have a huge project for which I am trying to learn some PL/SQL.
    Context:
    Entry gets put into the Orders table. What I want to do is create a trigger( out of scope for this question) that takes the last entry's product ID number and performs a count of all the PID's that match it. Then I want to compare that number with a number in the ProductTransaction table.
    I.e.
    Orders ProductTransaction
    OID TID
    PID PurchaseCount
    o_TID Price
    etc.....
    Last entry that gets put in contains
    OID PID TID
    4 100 2
    ProductTransaction
    TID PurchaseCount Price
    2 10 100.00
    What I want to do is if the last entry into the Orders table was the OID 4 then I want to count all PID=100 and determine if the PurchaseCount has been reached yet.
    The only thing I can think of is the following, but it doesn't ensure that the last PID is what we are counting:
    declare
    v_countpid number;
    begin
    select
    count(pid) into v_countpid
    from
    orders
    where OID = (select last(oid) from orders);
    dc
    Im thinking something like the above which populates the v_countpid
    and then taking another variable which is a select into which takes the last TID entered and comparing them in an if statement of some sort
    Let me know your thoughts on this....

    They you both for your replies. I was pushing myself to stay up late last night and I guess I didn't included everything.
    Here it goes.
    The concept is to have someone buy a product lets say at 10 dollars and it will take 10 other people for you to finally get your product released to you.
    So when I purhcase PRODUCT A and put the entry into the orders table it will be something like this:
    OID = 1
    PID = 101
    TID = 2
    TIMEOFPURCHASE=<timestamp>
    etc........
    Now once that is entered into the table I am going to have a trigger as an after insert that will count the total PID's in the table that match what I just put into it, as in this case it was PID=101. The count of PID=101 will then be matched against the ProductTransaction PurchaseCount field to determine if that product should be released to the person with the lowest timestamp.
    So....
    ProductTransaction
    TID=2
    PRICE=$10
    PurchaseCount=10
    ORDERS
    OID PID TID TOP
    1 101 2 3 am
    2 101 2 5 am
    3 30 1 12 pm
    4 101 2 4 pm
    Example. The last entry was OID=4 so it will count up the number of PID=101 and then that number is compared against ProductTransaction purchase count. If hasn't exceeded then nothing happens. If the number is matched then OID=1 is moved into the shipping table for processing.
    Let me know if this still doesn't clarify, or if there is a better way to do this....

  • Can I be selective with count()?

    I need to count the number of rows in a table that have a char value set to "1" as opposed to "0".
    Here is my SQL now...
    select m.name "MODULE", count(b.bcr_number) "TOTAL"
    from bcrs b, lk_modules m, bcr_req_mgt rm
    where b.primary_module_id = m.id
    and rm.bcr_id = b.id
    and rm.is_historical = 0
    group by m.name
    order by m.name;Here is what I would like to do...
    select m.name "MODULE", count(b.bcr_number) "TOTAL", count(rm.is_locked = 0) "REQ_MAN_LOCKED"
    from bcrs b, lk_modules m, bcr_req_mgt rm
    where b.primary_module_id = m.id
    and rm.bcr_id = b.id
    and rm.is_historical = 0
    group by m.name
    order by m.name;That way I will only get a count of the records that are "locked" and not all of them.
    Any suggestions will be appreciated.
    Thanks.

    You can use the CASE statement as well:
    select
      m.name "MODULE",
      count(b.bcr_number) "TOTAL",
      count(CASE WHEN rm.is_locked = 0 THEN 1 ELSE NULL END) "REQ_MAN_LOCKED"
    from
      bcrs b,
      lk_modules m,
      bcr_req_mgt rm
    where b.primary_module_id = m.id
      and rm.bcr_id = b.id
      and rm.is_historical = 0
    group by
      m.name
    order by
      m.name;

  • Sum() in select query

    Hi,
    How to avoid getting empty row when sum() function returns no value if the condition fails in where clause?
    TIA
    Harish

    SQL> select sum(cnt) sm
      2  from t;
            SM                                                                     
    SQL> select sum(cnt) sm
      2  from t
      3  minus
      4  select null sm
      5  from dual;
    no rows selected                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Sum in select provides 0

    Hi Experts,
    I've createtd  a SQL statement like tjis:
    select
              comp1 comp2 sum( Value1 )
              from DB_TAB into correspondng fields of structure1 gourp by comp1 comp2 .......
    This works fine and actually calculates sums as expected. Due to new requirements I've to create staement dynamically.
    Result:
    select
            (select_tab)
            from (ttab) into correspondng fields of <structure> group by (group_tab).....
    This select also works, but instead of a sum, value 0 is provided. Syntax check is okay, program runs withosut any
    error and  select_tab, ttab, <structure> and group_tab are containing desired values as coded in the first scanario.
    I'm not really familiar to ABAP and this issue drives me crazy.
    Please help!
    Thamks in advance and
    Ragards
    Joe

    Hi Adruian,
    code looks like this
    *SELECT_TAB:
    CONCATENATE '/BIC/'  LV_SOURSYSID 'VKORG'    INTO WHERE_LINE.
    APPEND WHERE_LINE TO SELECT_TAB.
    CONCATENATE '/BIC/'  LV_SOURSYSID 'MEINS'    INTO WHERE_LINE.
    APPEND WHERE_LINE TO SELECT_TAB.
    CONCATENATE 'SUM( /BIC/' LV_SOURSYSID 'ABSMG )' INTO WHERE_LINE.
    APPEND WHERE_LINE TO SELECT_TAB.
    *GROUP_TAB
    CONCATENATE '/BIC/'  LV_SOURSYSID 'VKORG'     INTO WHERE_LINE.
    APPEND WHERE_LINE TO GROUP_TAB.
    CONCATENATE '/BIC/'  LV_SOURSYSID 'MEINS'     INTO WHERE_LINE.
    APPEND WHERE_LINE TO GROUP_TAB.
    *TTAB
    CONCATENATE '/BIC/A' LV_SOURSYSID 'OSDS00' INTO TTAB.
    I want to write a routine in BW, which is valid for each source system without any further adoption.
    LV_SOURSYSID can be determined within this routine.
    Thanks
    Joe

  • HELP - SQL and Select and COUNT

    Hi Anyone or Everyone...
    I have created this SQL Statement in java
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'C%' GROUP BY #PART ORDER BY #PART
    this is the error I get....If I remove the Count(#PART) works fine so the column #PDESC is fine....what is wrong with this?? Thanks in advance!!
    [SQL0122] Column #PDESC or expression specified in SELECT list not valid.

    Hi Anyone or Everyone...
    I have created this SQL Statement in java
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB
    WHERE #PART LIKE 'C%' GROUP BY #PART ORDER BY #PART
    this is the error I get....If I remove the
    Count(#PART) works fine so the column #PDESC is
    fine....what is wrong with this?? Thanks in advance!!
    [SQL0122] Column #PDESC or expression specified in
    SELECT list not valid.Hi there
    When you are querying on a table, either you have to specify individual elements (columns) of the table or aggregations of the columns. In your case, the elements you are querying are : #PART, #PDESC and PCOUNT. Here, PCount is an aggregation that is calculated form COUNT(#PART) and #PART is also an aggregation as you are grouping the query results by #PART. But, What bout #PDESC? You are querying as individual column only and doing nothing with it. That was the problem.
    Tip: Try adding "GROUP BY #PDESC" or "COUNT(#PDESC)" to your query and I hope it shud work.
    May be It won't solve your problem and give the result that you need, but you will understand the point I am trying to explain.
    Cheers
    -Uday

  • Select and Count not working.....HELP PLEASE!!

    I have the following scenerio:
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AN101011%' AND #RECDT BETWEEN 19970826 AND 20020826 GROUP BY #PART,#PDESC
    //brings back count of 1 which is right...only one part within the date range
    PCOUNT: 1
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AC043208%' OR #PART LIKE 'AN101011%' AND #RECDT BETWEEN 19970826 AND 20020826 GROUP BY #PART,#PDESC
    //looped through result set and these two counts are right
    PCOUNT: 1
    PCOUNT: 1
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AN101011%' OR #PART LIKE 'AC043208%' AND #RECDT BETWEEN 19970826 AND 20020826 GROUP BY #PART,#PDESC
    //now brings back a pcount of 2 for the first part which is shouldn't, there are two parts with the same number but only one which falls within the date range.
    PCOUNT: 2
    PCOUNT: 1
    could anyone help me with this.....thanks in advance

    Found the solution....its in the order of processing of the select statement...for others future reference....
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AN101011%' AND #RECDT BETWEEN 19970826 AND 20020826 GROUP BY #PART,#PDESC
    //brings back count of 1 which is right...only one part within the date range
    PCOUNT: 1
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AC043208%' OR #PART LIKE 'AN101011%' AND #RECDT BETWEEN 19970826 AND 20020826 GROUP BY #PART,#PDESC
    //looped through result set and these two counts are right
    PCOUNT: 1
    PCOUNT: 1
    //*****this works because in actual fact it is reading the date range and it associates it with the last part number so it reads it like this (note the brackets):
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AC043208%' OR (#PART LIKE 'AN101011%' AND #RECDT BETWEEN 19970826 AND 20020826) GROUP BY #PART,#PDESC
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AN101011%' OR #PART LIKE 'AC043208%' AND #RECDT BETWEEN 19970826 AND 20020826 GROUP BY #PART,#PDESC
    //now brings back a pcount of 2 for the first part which is shouldn't, there are two parts with the same number but only one which falls within the date range.
    PCOUNT: 2
    PCOUNT: 1
    //***this did not work because the date range only applied to the last part number not the first..so it read it like (note the brackets):
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE #PART LIKE 'AN101011%' OR (#PART LIKE 'AC043208%' AND #RECDT BETWEEN 19970826 AND 20020826) GROUP BY #PART,#PDESC
    //**Therefore, I changed it to (including the brackets) and it ran fine:
    SELECT #PART,#PDESC,COUNT(#PART) AS PCOUNT FROM MYLIB WHERE (#PART LIKE 'AN101011%' OR #PART LIKE 'AC043208%') AND #RECDT BETWEEN 19970826 AND 20020826 GROUP BY #PART,#PDESC

  • Sum in select

    Hi all,
    I have an internal table consisting of three fields. I want to populate the internal table using a select statment for where I sum all records returned by material. Here is my query without the select:
      SELECT PRINS PRLAB PREIN
      INTO TABLE GT_MSPR_FIELDS
      FROM MSPR
      FOR ALL ENTRIES IN GT_SUPPLY_DEMAND
      WHERE MATNR EQ GT_SUPPLY_DEMAND-MATNR       
      AND   WERKS EQ GT_SUPPLY_DEMAND-WERKS       
      AND   PSPNR IN S_PSPNR.                    
    I tried adding a SUM statment to each field but the select poops. Is there a way to do this?
    regards,
    Mat

    Hi Bjorn,
    I have an itab that includes matnr prins prlab prein
      SELECT MATNR sum(PRINS) sum(PRLAB) sum(PREIN)
      INTO TABLE GT_MSPR_FIELDS
      FROM MSPR
      FOR ALL ENTRIES IN GT_SUPPLY_DEMAND
      WHERE MATNR EQ GT_SUPPLY_DEMAND-MATNR       
      AND   WERKS EQ GT_SUPPLY_DEMAND-WERKS       
      AND   PSPNR IN S_PSPNR.                    
    that is what I had in mind....thanks much.

  • Need to run a query to select # of counts based on each month

    Let's say I have a talble with 12 months, each month has some data.
    I want to run a select count(*) to get result of how many rows per month, like Jan----100, Feb---90, etc.
    How do I do that?
    Thanks in advance.

    user569151 wrote:
    Let's say I have a talble with 12 months, each month has some data.
    I want to run a select count(*) to get result of how many rows per month, like Jan----100, Feb---90, etc.
    How do I do that?
    Thanks in advance.May be like this:
    SELECT EXTRACT(MONTH FROM date_column),COUNT(*)
    FROM TABLE_NAME
    GROUP BY EXTRACT(MONTH FROM date_column);

Maybe you are looking for

  • Help with my error message

    this is my second iPOD with the same error message. "Attempting to copy to the disk "CYNDIEBRAY" failed. The disk could not be read from or written to." can someone help me use my iPOD.. the genius desk just exchanged my other on. i have a new 80GB a

  • CMC Default settings parameter prompt error

    Hi, When setting the parameters in CMC Default Settings, the parameters are not properly populated. The dynamic prompt parameter populated correctly And again the same dynamic parameter values populated when the immediate next parameter is being edit

  • How Can You Add New MP3s to itunes without Duplicating Existing Songs

    Is there a way to get iTunes to search my music folder and only add song not already in my library? I rip all my music as MP3s with CDex so I can have some music at work (We're not allowed to install programs at work so I have to use Media Player the

  • More slideshow transition effects

    Fade, horizontal, and vertical are nice but kind of boring.  Are there any plans to have more transition effects in slideshows, like some of the ones in PowerPoint like: - Blinds Horizontal - Blinds Vertical - Box In - Box Out - Checkerboard Across -

  • Aufruf worddatei aus pdf

    Hallo zusammen, ist es möglich eine worddatei aus einer pdf-Datei kommentarlos bzw. ohne irgendwelche Abfragen durch den Adobe Reader X aufzurufen. Hintergrund: Die pdf wurde in Word erzeugt, das andere Dokument als Hyperlink hinterlegt. Dann als pdf