Query Oracle to view a single employee for all departments

Hello

I'm looking for an efficient query which will display a report with the rest of columns

Dept | Employee ID

(Field of join is DEPT_ID)

Where departments are stored in the DEPT table and the employee list is stored in the EMP table. What I want is a join between 2 tables, but display only one employee (any random) for each Department.

At the moment if I fire the inner join, it displays all employees from the EMP table.

Buxant

Hello

What a strange requirement. Any name of emp?

Then get anyone with a scalar subquery:

with got_emp as
(
select dname
    , (select em.ename
          from emp em
        where d.deptno = em.deptno
          and rownum <= 1
      ) ename
  from dept d
)
select *
  from got_emp
where ename is not null;

Kind regards.

Alberto

Tags: Database

Similar Questions

  • Can I change the license for a single Application for all Applications?

    In December 2014, I bought a license for Adobe Illustrator? However, it seems, I also need less inDesign and Photoshop, is it possible to switch to continue the license but applications instead of buying a single license for each program?

    Please contact our phone/Chat for the same support: contact customer service

    *Remember to stay signed with your Adobe ID ( email id used to purchase the subscription ) before accessing the link above*.

    Select the exact options listed below for support options:

    Let us know if that helps.

    Kind regards

    BANI

  • A single application for all the resources of the target in IOM

    Hi guys

    I have a requirement, once a user is created in the IOM then it should be placed in service in all the resources of the target with the single level approval workflow. How we handle this?

    I have in mind one of the approaches is

    Creating a strategy for access with approval and adding the target resources to access this policy.

    So after creating the user, this access policy triggers and sends the request to the authorizing server.

    After its approval, all the resources are going to get put into service for the user.

    Does this approach work? Is there a better approach?

    I think you will want to use a generic object, even if you do not want. I think you need to create a unique group of IOM with an access policy for all these objects and object of generic resource, add the user to the IOM group and delete the user for cancellation. So I think you should create another access strategy to get the generic resource for all users and have an approval related to this. This should give you an approval for the "All Access" resource object, which then gives access to all others.

    -Kevin

  • Reclassification of the single application for all applications

    Hi, I am running Adobe CS 5 on my desktop and I think with the purchase of an annual subscription for Illustrator CC. If I choose to upgrade to 'All the Apps' at some point during my subscription, which is possible (so that I don't pay $19.99 for Illustrator and $49.99 for all applications). Or should I expect for my (paid monthly) annual subscription expire everything first? Thank you.

    You can change or upgrade your membership at any time. Please see the update or change your plan Adobe Creative cloud for more information.

    Concerning

    Hervé Khare

  • Adding a constant to a single channel for all pixels in a selection

    I have a selection in a document Photoshop RGB.  I would like to add a constant value (say + 16, for example) for all red values for each pixel in the selection.  Is there an easy way to do this?

    Kind regards

    Charles

    Way the easiest would be to channel mixer.

    Second easy mode of fusion linear density (addition) and a layer of constant value would be.

  • SQL query to retrieve a single record for each employee of the following table?

    Hi all

    Help me on the writing of SQL query to retrieve a single record for each employee of the following table? preferably a standard SQL.

    CREATE TABLE xxc_contact)

    empnum NUMBER,

    alternatecontact VARCHAR2 (100),

    relationship VARCHAR2 (10),

    phtype VARCHAR2 (10),

    Phone NUMBER

    );

    insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Cell', 9999999999)

    insert into xxc_contact values (123456, 'Rick Grimes', 'SP', 'Work', 8888888888)

    insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Work', 7777777777)

    insert into xxc_contact values (123457, 'Daryl Dixon', 'EN', 'Home', 3333333333)

    insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Cell', 9999999999)

    insert into xxc_contact values (123456, 'Maggie Greene', 'CH', 'Home', 9999999999)

    expected result:

    EmpNum AlternateContact Relationship PhType Phone       

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    Thanks in advance.

    994122 wrote:

    Thank you all, that I got a result

    http://www.orafaq.com/Forum/m/620305/#msg_620305

    By Lalit Kumar B...

    Specifically, the two simple solutions provided were:

    1 using the row_number, entitled Oracle ranking based on descending order of the inside telephone each empnum group. And finally selects the lines which has least rank (of least since that order is descending for phone).

    SQL > column alternatecontact format A20;

    SQL >

    SQL > SELECT empnum, alternatecontact, relationship, phtype, phone

    2 from (SELECT a.*, row_number() over r (PARTITION BY empnum ORDER BY phone / / DESC))

    3 FROM xxc_contact one)

    4. WHEN r = 1

    /

    EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE

    ---------- -------------------- ---------- ---------- ----------

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    2. with the help of MAX, Oracle automatically assigns the maximum phone for all the rows in each group of empnum. And finally selects the rows with the maximum phone. Order by clause is omitted here intentionally. You can find out why.

    SQL > SELECT empnum, alternatecontact, relationship, phtype, phone

    2 (SELECT a.*, MAX (phone) over (PARTITION BY empnum) rn FROM xxc_contact one)

    3 WHERE phone = rn

    4.

    EMPNUM ALTERNATECONTACT RELATIONSHIP PHTYPE PHONE

    ---------- -------------------- ---------- ---------- ----------

    123456 rick Grimes SP cell 9999999999

    Daryl Dixon EN work 7777777777 123457

    Home 123458 Maggie Greene CH 6666666666

    Kind regards

    Lalit

  • 8.1 Windows mail app - single mailbox for multiple accounts as on Windows phone?

    I have an outlook.com account and a microsoft exchange account - windows Phone I can combine the mailboxes of these accounts. I can not figure out how to do it on Windows 8 mail and have to check both and constantly move from one to the other, which is more disruptive as it sounds. Can I view a single mailbox for both accounts in Windows mail 8.1, similar to how I'm currently doing it in Windows Phone 8.0? I must warn you that any response in addition to 'Yes' is followed with a request for an explanation.

    Hi Mathenge,

    Unfortunately, no.  With the Mail application on Windows 8.1, you can have all your email from the Outlook.com account, Gmail, Yahoo! and Exchange in a single application, but not as a unique mailbox.

    You can check out this tutorial and understand the full operation of Windows Mail on Windows 8.1 application

    http://Windows.Microsoft.com/en-in/Windows-8/mail-app-tutorial

    Hope this information helps.

  • Can we have a space for documents, created by the members, approved by oracle dignitory and shared for all?

    Dear all,

    Is it possible that we have a space where all documents... created by members... regarded as valuable and approved by an authorized Oracle... and shared staff for all...

    This can be useful for generations to come... I strongly believe...

    Simply add to the question under: can we share with the Community (related to oracle) document which can be useful for someone..?

    and allow users to create community Documents

    Thank you and best regards,

    Séverine Suresh

    ... I agree!

    As Community Manager for the database and the spaces Dev App, I can

    work with you to post articles (in addition to blogging

    approach set out below.   If you want to publish an article, the first friend

    me, so we can communicate by message on the platform.

    And then create the document in your profile (HTML preferred) and cc: me as

    a collaborator. (@Laura Ramsey-Oracle)

    I can quickly passes in review (formatting and TM checks especially) and then I

    can move the article to the designated space.

    See you soon!

    LKR

  • I need to change my plan which is creative cloud single-app for Photoshop membership (one year) full - special offer to students

    I need to change my plan which is creative cloud single-app for Photoshop membership (one year) full - special offer to students

    Single update for all http://forums.adobe.com/thread/1235382 clouds can help

  • Can I change the annual plan of photoshop for all users?

    A few days ago, I joined the annual plan member ship, using photoshop and lightroom.

    But I need InDesign. Then I can be changed to all the user not separately?

    You can add only InDesign to your membership for $20 (U.S. price) or go to the total subscription

    Single update for all http://forums.adobe.com/thread/1235382 clouds can help

  • Plans of photographer for all switching applications keeps failing.

    Hey guys! I'm changing my plan of photographer to apply a plan all the app, but it won't let me finish the change. Can anyone help?

    Single update for all http://forums.adobe.com/thread/1235382 clouds can help

    or

    Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">

    Don't forget to stay signed with your Adobe ID before accessing the link below

    Creative cloud support (all creative cloud customer service problems)

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

  • query Oracle for top two salaries of each group departmentwise

    query Oracle for top two departmentwise salary

    sigh...

    But anyway,.
    Top - n queries:
    http://www.Oracle.com/technology/oramag/Oracle/07-Jan/o17asktom.html
    http://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:2853107469873
    and of course a lot of 'em here OTN...

  • Single request for the display of all, but the values of 1 column for all tables

    Hello

    All tables have the column SYS_CREATION_DATE.
    But I don't want to not display the value of this column

    Can anyone suggest a way in which I could achieve this?

    Oracle version: 11 GR 1 material
    OS: SunOS


    See you soon,.
    Malika

    Published by: user9131570 on July 6, 2010 19:57

    user9131570 wrote:
    @Tubby

    I * table-wise display the values of all but 1 columns (SYS_CREATION_DATE) in my database.*

    I need it to compare to another data base for all these values.

    I would like to make a wild guess at what you are getting.

    In view of these two tables

    create table emp
       (empid number,
        empname varchar2(15),
        empaddr   varchar2(15),
        sys_creation_date date);
    --
    create table dept
       (deptid number,
        deptmgr varchar2(10),
        sys_creation_date date);
    

    you want to combine somehow

    select empid,
             empname,
             empaddr
    from emp;
    

    with

    select deptid,
             deptmgr
    from dept;
    

    in a single sql statement?

  • We can share with the Community (related to oracle) document which can be useful for someone... ?

    Dear all,

    We can share with the Community (related to oracle) document which can be useful for someone... ? Is there a specific place, so that it... where, once that we download... our document is checked and published if it is deemed sufficiently credible... ?

    Thank you and best regards,

    Séverine Suresh

    Question has now moved to the space of the feedback from the community.

    The community provides for the possibility for members to upload documents to the content-> spaces of Documents in the workspace of each product (if available).  However, the feature is currently disabled for most members due to problems with spam, so only a few members (most of Oracle employees) have the necessary permissions to do this.

    The admin studying how they can implement something that would allow members to upload documents, etc., which also has some mechanism to prevent spam.

    There is an idea already created for this: allow users to create community Documents

    for the Admin provided details on their current attitude

  • Oracle Smart View 11.1.2.5.400 prompt bug still not fixed?

    Hello

    in our company we have 11.1.1.7.140715 OBIEE and we test Oracle Smart View 11.1.2.5.400 (Build 376) on Excel 2007 32-bit and Excel 2013 64 bits to allow our end users work easier.

    Unfortunately, almost all of our reports contains guests and when you try to insert an object in the Excel worksheet, we see the 'object' error reference not set to an instance of an object and Excel crashes.

    Is there a solution?

    Thank you very much.

    Hello

    Check out the following:

    When you try to import a report, a Pop Up shows Up in Excel with the following error: "object reference not set to an instance of an object" (Doc ID 1952856.1)

    Noticed that:

    CAUSE

    Caused by a code bug introduced in 11.1.1.7.140715 patch bundle. Also occurs in 11.1.1.7.141014.

    Duplicated 7.140715 symptoms and could not on 7.140527.

    Bug 19545187 - SMARTVIEW 11.1.2.3 ERROR: OBJECT REFERENCE NOT SET to THE INSTANCE OF AN OBJECT - duplicate of below
    Bug bug 19682114 - of the COLUMNFILTERPROMPTDEFN LABEL OBJECT IS NULL for all NEW CREATED REPORTS - internal

    SOLUTION

    Apply Patch 19682114 - COLUMNFILTERPROMPTDEFN LABEL OBJECT IS NULL FOR ALL NEW REPORTS CREATED

Maybe you are looking for

  • do not want to synchronize new ipad2

    I have a new ipad2 I've never had an apple product. I like and use firefox on my pc and my laptop windows 7. I need to sync my ipad with other pc products. I can't past this stage in loading the app for my ipad how to do that. Thank you, Glen a.

  • extension memory for BB 10 and ripple model

    Hello world I hope I'm not duplicating something but I can't seem to find anything on the combination of the extension memory BB10 BB10 and ripple model. I followed the instructions exactly.  I built the project and placed in the directory ext SDK in

  • How can I get all the file in a directory name?

    Purpose: Try to get all the file in a directory name. My code: FileConnection fconn = (fileDirectory) Connector.open (FileConnection);Listing files = fconn.list ();Listing files = fconn.list ("*", true); Try_SCREEN.updateDisplay (files); txt shows un

  • Why windows 7 says it is not genuine, when it is authentic

    At least once a day, this message appears in the lower right. When I right click on computer and go to properties, it says windows is activated

  • How to find the location of a file or folder in windows 7

    I have a few games on my computer. I can't find the location of the original file for them however. What I find is that they are in the 'games' folder that is included with windows 7. However, the whole files are not there. Only a little bit of infor