Matching EMP and DEPT

Hi all,
11.2.0.1
I have departments in table DEPT which are  10 and 20. Department 10 has 100 employees in EMP while Department 20 has none in EMP, so it has no matching rows.
How can I create a query such that all dept with no EMP will be displayed:
DEPT      EMP
====      ====
10         100
20           0
30          20
Thanks,
pK

select d.deptno
,      (select count(*) from emp e where e.deptno = d.deptno) emps
from   dept d;
-- or:
select *
from ( select d.deptno
       ,      (select count(*) from emp e where e.deptno = d.deptno) emps
       from   dept d
where emps = 0;

Similar Messages

  • How to get emp and dept tables of scott schema if they acdientally deleted

    Hii I accedentally modifiled emp and dept tables in scott schema.... Can you please tell how to recreate fresh emp and dept tables ? is there any way to get emp and dept tables? please help regarding this

    If you are on Oracle 10g version...
    The demo tableds under scott schema can be created using oracle supplied script.
    http://www.oracle.com/technology/sample_code/tech/sql_plus/htdocs/demobld.html
    Alternatively, this script exists in $ORACLE_HOME/sqlplus/demo directory.
    vr,
    Sudhakar B.

  • Emp and Dept table from JDeveloper tutorial

    Hi all,
    Under the tutorial for JDeveloper, I was going through the section 'Creating a Java Form Applet Using Wizard'. In one step, it asks to select 'Tables' - 'Emp' and 'Dept', but, the steps prior to that doesn't tell you how to add those tables in the database since I'm using my own database. Does anybody know where I can find the SQLScript to add these tables?
    Regards,
    AR

    The samples are based on the EMP and DEPT tables, which are typically owned by Scott (password tiger). Check first to see if this user exists in the database (it is created automatically when you do a default database creation). Otherwise, you can find the script in ORACLE_HOME\rdbms\admin\scott.sql.
    -- Brian

  • Emp and Dept tables

    Hi,
    I believe that when the database is installed, a few tables are created which all users have access to, i.e. emp and dept.
    Can anyone explain to me a bit more about where they are stored and particually where I can locate the scripts for these tables.
    Cheers,
    Nick

    run $ORACLE_HOME\sqlplus\demo\demobld.sql as the user in which you want to install these test tables. Historically, this has been in the SCOTT schema.
    HTH-Kevin

  • Emp and Dept Table Dropped

    Hi ,
    I have mistakenly altered and dropped the Employee and Department Table.
    Can anybody help me with the Structure and Data of these tables ?
    Or provide me with a procedure to re-create the Emp and Dept table ?
    Thanks,
    Nisha

    Thank you very much !! That really helped.
    You just have to execute that file.
    For Eg in SQLPLUS : Just say ---> @D:\oracle\ora92\sqlplus\demo\demobld.sql

  • Data needed from emp and dept tables

    Wondering if somebody can querry the emp table and dept table that comes with some versions of oracle already built in.
    I need the data produced from these two querries
    select * from emp
    select * from dept

    If you look in ORACLE_HOME/sqlplus/demo you'll find demobld.sql which contains the script the build all the scott tables.

  • EMP and DEPT sampledata query (SOLVED)

    I don't have access to create tables at work - just to run selects on existing tables.
    I've used the SQL below to use the 2 standard Oracle test dept and emp tables for testing, but - is it possible to use SQL to join the tables, or can the GET table WITH table AS ... SQL only ever work on one table at a time, rather than allowing joins to be done?
    Thanks
    GET dept
    WITH dept AS
         (SELECT 10 deptno
               , 'ACCOUNTING ' dname
               , 'NEW YORK' loc
            FROM DUAL
          UNION ALL
          SELECT 20 deptno
               , 'RESEARCH   ' dname
               , 'DALLAS' loc
            FROM DUAL
          UNION ALL
          SELECT 30 deptno
               , 'SALES      ' dname
               , 'CHICAGO' loc
            FROM DUAL
          UNION ALL
          SELECT 40 deptno
               , 'OPERATIONS ' dname
               , 'BOSTON' loc
            FROM DUAL)
    SELECT *
      FROM dept;
    GET emp
    WITH emp AS
         (SELECT 7369 empno
               , 'SMITH' ename
               , 'CLERK' job
               , 7902 mgr
               , '17-Dec-80' hiredate
               , 800 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7499 empno
               , 'ALLEN' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '20-Feb-81' hiredate
               , 1600 sal
               , 300 comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7521 empno
               , 'WARD' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '22-Feb-81' hiredate
               , 1250 sal
               , 500 comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7566 empno
               , 'JONES' ename
               , 'MANAGER' job
               , 7839 mgr
               , '02-Apr-81' hiredate
               , 2975 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7654 empno
               , 'MARTIN' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '28-Sep-81' hiredate
               , 1250 sal
               , 1400 comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7698 empno
               , 'BLAKE' ename
               , 'MANAGER' job
               , 7839 mgr
               , '01-May-81' hiredate
               , 2850 sal
               , NULL comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7782 empno
               , 'CLARK' ename
               , 'MANAGER' job
               , 7839 mgr
               , '09-Jun-81' hiredate
               , 2450 sal
               , NULL comm
               , 10 deptno
            FROM DUAL
          UNION ALL
          SELECT 7788 empno
               , 'SCOTT' ename
               , 'ANALYST' job
               , 7566 mgr
               , '19-Apr-87' hiredate
               , 3000 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7839 empno
               , 'KING' ename
               , 'PRESIDENT' job
               , NULL mgr
               , '17-Nov-81' hiredate
               , 5000 sal
               , NULL comm
               , 10 deptno
            FROM DUAL
          UNION ALL
          SELECT 7844 empno
               , 'TURNER' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '08-Sep-81' hiredate
               , 1500 sal
               , NULL comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7876 empno
               , 'ADAMS' ename
               , 'CLERK' job
               , 7788 mgr
               , '23-May-87' hiredate
               , 1100 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7900 empno
               , 'JAMES' ename
               , 'CLERK' job
               , 7698 mgr
               , '03-Dec-81' hiredate
               , 950 sal
               , NULL comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7902 empno
               , 'FORD' ename
               , 'ANALYST' job
               , 7566 mgr
               , '03-Dec-81' hiredate
               , 3000 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7934 empno
               , 'MILLER' ename
               , 'CLERK' job
               , 7782 mgr
               , '23-Jan-82' hiredate
               , 1300 sal
               , NULL comm
               , 10 deptno
            FROM DUAL)
    SELECT *
      FROM emp;

    is it you requirement.
    WITH dept AS
         (SELECT 10 deptno
               , 'ACCOUNTING ' dname
               , 'NEW YORK' loc
            FROM DUAL
          UNION ALL
          SELECT 20 deptno
               , 'RESEARCH   ' dname
               , 'DALLAS' loc
            FROM DUAL
          UNION ALL
          SELECT 30 deptno
               , 'SALES      ' dname
               , 'CHICAGO' loc
            FROM DUAL
          UNION ALL
          SELECT 40 deptno
               , 'OPERATIONS ' dname
               , 'BOSTON' loc
            FROM DUAL),
    emp AS
         (SELECT 7369 empno
               , 'SMITH' ename
               , 'CLERK' job
               , 7902 mgr
               , '17-Dec-80' hiredate
               , 800 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7499 empno
               , 'ALLEN' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '20-Feb-81' hiredate
               , 1600 sal
               , 300 comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7521 empno
               , 'WARD' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '22-Feb-81' hiredate
               , 1250 sal
               , 500 comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7566 empno
               , 'JONES' ename
               , 'MANAGER' job
               , 7839 mgr
               , '02-Apr-81' hiredate
               , 2975 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7654 empno
               , 'MARTIN' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '28-Sep-81' hiredate
               , 1250 sal
               , 1400 comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7698 empno
               , 'BLAKE' ename
               , 'MANAGER' job
               , 7839 mgr
               , '01-May-81' hiredate
               , 2850 sal
               , NULL comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7782 empno
               , 'CLARK' ename
               , 'MANAGER' job
               , 7839 mgr
               , '09-Jun-81' hiredate
               , 2450 sal
               , NULL comm
               , 10 deptno
            FROM DUAL
          UNION ALL
          SELECT 7788 empno
               , 'SCOTT' ename
               , 'ANALYST' job
               , 7566 mgr
               , '19-Apr-87' hiredate
               , 3000 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7839 empno
               , 'KING' ename
               , 'PRESIDENT' job
               , NULL mgr
               , '17-Nov-81' hiredate
               , 5000 sal
               , NULL comm
               , 10 deptno
            FROM DUAL
          UNION ALL
          SELECT 7844 empno
               , 'TURNER' ename
               , 'SALESMAN' job
               , 7698 mgr
               , '08-Sep-81' hiredate
               , 1500 sal
               , NULL comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7876 empno
               , 'ADAMS' ename
               , 'CLERK' job
               , 7788 mgr
               , '23-May-87' hiredate
               , 1100 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7900 empno
               , 'JAMES' ename
               , 'CLERK' job
               , 7698 mgr
               , '03-Dec-81' hiredate
               , 950 sal
               , NULL comm
               , 30 deptno
            FROM DUAL
          UNION ALL
          SELECT 7902 empno
               , 'FORD' ename
               , 'ANALYST' job
               , 7566 mgr
               , '03-Dec-81' hiredate
               , 3000 sal
               , NULL comm
               , 20 deptno
            FROM DUAL
          UNION ALL
          SELECT 7934 empno
               , 'MILLER' ename
               , 'CLERK' job
               , 7782 mgr
               , '23-Jan-82' hiredate
               , 1300 sal
               , NULL comm
               , 10 deptno
            FROM DUAL)
    SELECT *
      FROM emp,dept
      where emp.deptno =dept.deptno

  • Issue with the functions "add matching sets" and "modify matching sets"

    Hi,
    Though 'None' access permission is set for the functions 'Add Matching Sets' and 'Modify Matching Sets', they are accessible.
    Is this a bug with the tool? or am I missing something?
    Thanks in advance,
    Madan

    sorry, missed the version details.
    I'm using MDM 5.5 SP6.

  • HT4914 I often record songs at a particular tempo, iTunes Match will then match it and send it back to me at the original tempo, is there anyway I can stop some songs from being matched. At the moment I have turned match off. But I would like to sync play

    I often record songs at a particular tempo, iTunes Match will then match it and send it back to me at the original tempo, is there anyway I can stop some songs from being matched. At the moment I have turned match off. But I would like to sync playlists.

    How old was this backup? It sounds like it was at least several weeks old.
    You can look directly in the TM backup for the music.
    1. Connect to the external HDD the backup is kept on.
    2. Open a Finder window and select the backup drive in the left hand panel. Double click into the folders until you see a list of folders with dates.
    These are the incremental backups. You can start at the top or the bottom of the list but I suggest you double Latest/<HDD Name>/Users/<Account Name>/Music/iTunes/iTunes Media/Music. From this location you can start looking for the "missing" music. When/if you find it you can simply drag-n-drop to ~/Music/iTunes/iTunes Media/Music on the internal HDD.
    If the music is actually not in the backups (for whatever reason) then you've got a problem.
    You can download the uploaded files from the cloud by deleting the affected tracks from the iTunes library (but not the cloud!), highlighting multiple tracks at once, right-clicking and choosing "download."

  • Matching Raster and Vector RGB color in InDesign CS3.

    We print on a Durst Lambda RGB imaging device to photographic paper. All color management is done as an early bind (raster files are converted to the printer's color space and vector colors are chosen from a palette database). So basically the files must go through InDesign without any color change in raster or vector information. We have clients that require specific RGB builds for logo colors the are present in both their raster and vector files.
    Color Management is set to "North American General Purpose 2" with "RGB: Preserve Embedded Profiles" selected.
    1) The file is exported as a PDF 1.4, High Quality, PDF/X_None.
    2) The PDF was ripped on a Cheetah RIP (Jaws level 3) with no color management on.
    3) Solid raster colors such as 0-255-0 will reproduce as 0-255-1.
    4) The color differences between the raster and vector are usually 1-4 points.
    5) The vector is consistent as was input in the programit's only the raster that changes. When you are trying to match raster and vectors logo colors it is a killer.
    However, I can go into the InDesign (or Illustrator) color settings and turn color management off (This is our current workflow). In doing this the RGB working space uses the monitor profile and "color management policies" are set to OFF. With these settings the RGB raster and vector match. The problem with this work flow is two fold:
    1) We have other devices than our RGB Durst Lambda that can use the InDesign color managementVutek flat bed 3200 and grand format 3360.
    2) We have had many occurrences where the custom "color management off" settings have reverted back to the default "North American General Purpose 2"without any intervention.
    I have tried this with different RIP's with the same results.
    Does anyone have an idea to create a simple PDF workflow and keep the color information consistent?
    Program: InDesign CS3 5.0.2
    Platform: Mac OS 10.5.2
    Computer: G5 tower with 4 gigs of RAM

    I believe that setting is an old Illustrator setting that has been saved to effectively turn the color management off. The monitor profile effects the image displayedit doesn't effect the color transform.
    Anyway, the color management I want to use is the "North American General Purpose 2".
    To reiterate:
    The procedure:
    1) The file is exported as a PDF 1.4, High Quality, PDF/X_None.
    2) The PDF was ripped on a Cheetah RIP (Jaws level 3) with no color management on.
    The Problem:
    3) Solid raster colors such as 0-255-0 will reproduce as 0-255-1It changes from the original raster color placed in InDesign.
    4) The color differences between the raster and vector are usually 1-4 points.
    5) The vector is consistent as was input in the programit's only the raster that changes. When you are trying to match raster and vectors logo colors it is a killer.
    To summarize, the color of the raster file will change from the original that was place into the documenteven though nothing was selected in InDesign that would change the color (i.e. profile conversion to an output profile or a transparency effect used). The change is slightbut there.

  • HT204406 I am not able to download my files from iCloud to my iPad using iTunes Match, my internet connection is alive as I tested with Safari, I have enabled iTunes Match on and off to be usre is active..but still  cannot download....my music

    I am not able to download my files from iCloud to my iPad using iTunes Match, my internet connection is alive as I tested with Safari, I have enabled iTunes Match on and off to be usre is active..but still  cannot download....my music

    I have the same problem on my Windows 7 computer. In the right-click menu for a song one option is DELETE. However when I click that option the next window is to HIDE instead of DELETE. Apple, please help us with this.

  • FI and PCA doesn't match/Receivables and Payables?

    Hi!
    I have a problem with Profit center accounting. I try to match receivables and payables in FI and PCA, but they don't match (transaction KE5T).
    If I look transaction 1KEK, e.g. account xxxx shows 500.000 EUR. When I look e.g. transaction FS10N, the same account shows 800.000 EUR (cumulated balance).
    So all the entries have not transfered to PCA from FI. Whe have done the period-end transfers (transactions 1KEK and 2KES).
    So why not all the entries have transfered to PCA and how to fix this problem?
    Points will be given!

    Hi
    Please ensure that the referred GL account is added in T.Code 3KEH.
    If not, you have to add the same with a default PC and need to post all the existing documents posted in that GL account, manually to PCA using t.code 1KE8.
    Regards

  • Error : Contract does not match customer and item information[OSCI.ManufSN]

    I need to add Service Call from Service Contract through DIAPI. "Mfr. Serial no" is set as  "Unique serial no by" in system general settings.
    Creating two Customer Equipment Card from the cfl provided on Service Contract in Item Tab and Internal serial is blank in created Cutomer Equipment Card.
    One is terminated and other is active have the same ItemCode but different customers then while adding Service Contract I am paraller generating service call through DIAPI but the system is throughing error - "Contract does not match customer and item information [OSCL.IntrnalSN]"
    Thanks
    deepak gaur

    HI,
    Service Contract can be for a specific customer
    The contract type cound be (Coverage):
    1. including all items (Type Customer) in this case the dates of the coverage is defined in the head!
    2. Including specific serial numbers
    3. Including item groups
    The status every case should have to be Enabled/Approved  for valid contract (OCRT.Status = 'A').
    In case of Do not forget to set the valid from and valid to dates to define in the system the coverage. (header and items tab from/to dates)
    Now, If you create service all, the system will use the first possible Service Contract. IF you have more: you have to select the contract manually.
    Ex:
    1. One for customer including all items
    2. One for a specific serial number
    Best Regadrs,
    János

  • Match code and search help

    What is the difference between match code and search helps ?

    Hi,
    search help:
    adding f4 functionality is search help(adding help for any topic)
    http://help.sap.com/saphelp_erp2005/helpdata/en/3d/e53642e2a3ab04e10000000a1550b0/content.htm
    match code:
    adding search help for the input field is called as mathcode object
    http://help.sap.com/saphelp_40b/helpdata/en/cf/21ef1f446011d189700000e8322d00/content.htm
    Regards,
    Sravanthi

  • How to match mm and fi value

    HI
    I have finished goods material, where my mm side stock value say rs 50,000 (in mb5b),
    how to compare the FI side values?? in whch tcode?
    i couldn't get the exact values in mb5l ... where to check ?? and how to match mm and fi to have similar value

    Hi,
    The variance due to
    -You have entered postings to the stock account manually.
    -The stock account includes not only stock postings, but also other postings. In this case, you should check the account determination in the Customizing for Valuation and Account Assignment. Make sure that the stock accounts are used solely for the transaction key BSX (stock postings).Check Account Determination
    -The account assignment for the stock accounts (transaction key BSX) was changed .
    Common selection parameters to execute MB5L transaction are
    -Company Code
    -Valuation Area( if your company code have different valaution area that depents on the way you want to get the output)
    -Period ( 3 options you have current period, previous period and previous year)
    -Below that you have different output options to select
    Then execute (F8)
    The list with overview of stock by account with MM value and FI value. The values of MM and FI must be the same.
    For a good practise don not post any adjustment accounts to the stock accounts.
    Regards,
    Krishna Kishore

Maybe you are looking for

  • Forecast delivery schedules incorrect cumulative release quantity.

    Hi Gurus, We implemented the standard LZM - Scheduling agreement with delivery orders solution for component suppliers. The entire SAP standard configuration activated and the functionality is working correct. u2022     Scheduling agreement type LZM 

  • RHINTE20 and background processing

    Does anyone know how to set a variant when running RHINTE20? When I run the program it presents a list of objects to be corrected, and I manually select all the subtree with the icon and then run Create Several Objects.  It's these last two steps I'd

  • File to Idoc .If order is their need to send mail

    Hi All, I have scenario like this. Sending file (order) to SAP -IDoc I using RFC lookup .There is funtion module which has been developed in SAP R/3 it contains 5 import parameters and return SUBRC. If the result is  subrc = 4 This is the normal situ

  • Blogger RSS feed parser tool

    Hello everyone, Is there any j2ee RSS parsing Utility for reading Blogger feeds? The one I could find in the site http://java.sun.com/developer/technicalArticles/javaserverpages/rss_utilities/ is not parsing all the blogger feed elements. The tld has

  • Photography package issue

    this is an outstanding issue of over 7 weeks.  I am still trying to get a photography subscription running. There seems to be an issue with getting Lightroom 5 running.  I have recently cancelled a complete Creative Cloud subscription with your assis