Duplicate names..sql help?

Hi,
I am facing s problem hope you would help
I am running a query that shows me name of employees from a table with their
employee_ids
select emp_id, emp_name from t
EMP_ID     EMP_NAME 
1820       Waugh 
1920       King 
1936       Ric 
1940       Taylor 
2036       Smith 
2123       Paul 
2157       ALi 
2181       Smith 
2189       Joe 
2332       Bichel 
2333       Usman  I want that if there are more than ONE same EMP_NAMES returned by the query,
then query should not show the emp_name but instead should show 'duplicate
name' for matching names
so in my above data the name SMITH has come twice
so my desired output is
EMP_ID     EMP_NAME 
1820       Waugh 
1920       King 
1936       Ric 
1940       Taylor 
2036       DUPLICATE NAME 
2123       Paul 
2157       ALi 
2181       DUPLICATE NAME 
2189       Joe 
2332       Bichel 
2333       Usman  hope this will clear my requirement, I need the fastest and shortest possible
query to achieve this
CREATE TABLE T
(EMP_ID NUMBER(4),
EMP_NAME VARCHAR2(25))
INSERT INTO T VALUES (1820,'Waugh');
INSERT INTO T VALUES (1920,'King');
INSERT INTO T VALUES (1936,'Ric');
INSERT INTO T VALUES (1940,'Taylor');
INSERT INTO T VALUES (2036,'Smith');
INSERT INTO T VALUES (2123,'Paul');
INSERT INTO T VALUES (2157,'ALi');
INSERT INTO T VALUES (2181,'Smith');
INSERT INTO T VALUES (2189,'Joe');
INSERT INTO T VALUES (2332,'Bichel');
INSERT INTO T VALUES (2333,'Usman');
regards,

SQL> select emp_id
  2        ,decode((select count(*)
  3                from   t t2
  4                where  t2.emp_name = t1.emp_name)
  5               ,1, t1.emp_name
  6               ,0, '(name not found)'
  7               ,'DUPLICATE NAME'
  8               ) empname
  9  from t t1;
              EMP_ID EMPNAME
                1820 Waugh
                1920 King
                1936 Ric
                1940 Taylor
                2036 DUPLICATE NAME
                2123 Paul
                2157 ALi
                2181 DUPLICATE NAME
                2189 Joe
                2332 Bichel
                2333 Usman
11 rows selected.

Similar Messages

  • SQL-error "-955-Duplicate name" in DDL statement

    Hi!
    During upgrade preparations (PREPARE) i got follwing problem activating a table TAREF in SOLMAN32/MaxDB 7.5
    estos100:smpadm 79> more MVNTTOOL.ELG
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    MVNTABS errors and RETURN CODE in P060227.SMP
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    2EETP345 22:16:03: Retcode 1024: SQL-error "-955-Duplicate name" in DDL statement for "TAREF
    2EETP345                   "
    2EETP334 22:16:03: error in DDL, nametab for "TAREF" not activated
    1 ETP111 exit code           : "8"
    estos100:smpadm 80>
    When looking from the ABAP perspective (se14 -> table "TAREF" -> Indexes) I see that the table has two indexes:  
    "0   X   Primary index"
    "1   X   Index on Object Type".
    When looking at details for "index 1" it says "does not exist in database". 
    How do I solve this ABAP dictionary inconsistancy?
    Regards,
    Fredrik
    Message was edited by: Fredrik  Rosengren

    Hi Fredrik,
    please open an OSS message for your issue.
    Kind regards,
    Roland

  • Error Event ID 11 The KDC encountered duplicate names while processing a Kerberos authentication request.

    I've been noticing The Error with event ID 11 popping up a lot on our domain controllers:
    The KDC encountered duplicate names while processing a Kerberos authentication request.
    When running setspn -X it says that it found 111 groups of duplicate SPNs. However, when going through the list, it references domain service accounts that are used to run our SQL Server services. We have about 50 remote locations and each of them has 3
    machines participating in a SQL mirror (principal, mirror, witness) and they all run the SQL Server service on the same account (1 account per location).
    We haven't experienced any issues at all but I was wondering if this could cause problems or if we are straying from best practice. Any advice is welcome. Thanks!

    I believe what you should do to follow best practice is to provide unique SPNs for each SQL server, which will also provide increased security, and to do that you must create individual service account for each SQL server so it can associate that
    account with that server's SPN.
    Here's more on it to help guide you. Read Paul's comments, as well as other suggestions in the following thread:
    event ID 11 There are multiple accounts with name MSSQLSvc/xxxxxx
    http://social.technet.microsoft.com/Forums/windowsserver/en-US/8df35316-23ba-48ba-aa3e-2249fcbfecbc/event-id-11-there-are-multiple-accounts-with-name-mssqlsvcxxxxxx?forum=winserverDS
    Ace Fekay
    MVP, MCT, MCSE 2012, MCITP EA & MCTS Windows 2008/R2, Exchange 2013, 2010 EA & 2007, MCSE & MCSA 2003/2000, MCSA Messaging 2003
    Microsoft Certified Trainer
    Microsoft MVP - Directory Services
    Complete List of Technical Blogs: http://www.delawarecountycomputerconsulting.com/technicalblogs.php
    This posting is provided AS-IS with no warranties or guarantees and confers no rights.

  • Birthday calendar for only some of my contacts are showing up twice in my iPhone. They are not showing up twice tho on my iMac. No, I do not have duplicate names in my address book either. Any idea how to fix that?

    my birthday events for only some of my contacts are showing up twice in my iPhone. They are not showing up twice tho on my iMac. No, I do not have duplicate names in my address book either. Any idea how to fix that?

    I have uploaded the InDesign file so that you can take a closer look at:
    http://www.hsdesign.comuf.com/downloads/
    The file is called "Template_File.indd"
    So, as discussed the main issues are:
    1) The TOC doesn't generate all the listings (only those with the applied paragraph style "Heading 1 - Appendix")
    2) When I try to create a new pargraph style and apply it to existing or new text, it reads the pargraph style in the Paragraph Style menu, but the style doesn't actually apply.
    Hopefully you can figure something out from this. I really appreciate your help.
    Thanks!

  • The KDC encountered duplicate names while processing a Kerberos authentication request in a Domain controller server

    HI
    we have a sharepoint farm and in domain controller server, this error is in event viewer
    Log Name:      System
    Source:        Microsoft-Windows-Kerberos-Key-Distribution-Center
    Date:          9/15/2014 10:44:15 PM
    Event ID:      11
    Task Category: None
    Level:         Error
    Keywords:      Classic
    User:          N/A
    Computer:      XXXAPP01.xxxportal.com
    Description:
    The KDC encountered duplicate names while processing a Kerberos authentication request. The duplicate name is HTTP/XXXWFE01.xxxportal.com (of type DS_SERVICE_PRINCIPAL_NAME). This may result in authentication failures or downgrades to NTLM. In order to prevent
    this from occuring remove the duplicate entries for HTTP/XXXWFE01.xxxportal.com in Active Directory.
    Event Xml:
    <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
      <System>
        <Provider Name="Microsoft-Windows-Kerberos-Key-Distribution-Center" Guid="{3FD9DA1A-5A54-46C5-9A26-9BD7C0685056}" EventSourceName="KDC" />
        <EventID Qualifiers="49152">11</EventID>
        <Version>0</Version>
        <Level>2</Level>
        <Task>0</Task>
        <Opcode>0</Opcode>
        <Keywords>0x80000000000000</Keywords>
        <TimeCreated SystemTime="2014-09-15T19:44:15.000000000Z" />
        <EventRecordID>131824</EventRecordID>
        <Correlation />
        <Execution ProcessID="0" ThreadID="0" />
        <Channel>System</Channel>
        <Computer>XXXAPP01.xxxportal.com</Computer>
        <Security />
      </System>
      <EventData>
        <Data Name="Name">HTTP/XXXWFE01.xxxportal.com</Data>
        <Data Name="Type">DS_SERVICE_PRINCIPAL_NAME</Data>
        <Binary>
        </Binary>
      </EventData>
    </Event>
    adil

    Hi adil,
    Service principal names (SPNs) are stored as a property of the associated account object in Active Directory
    Domain Services (AD DS). I noticed that you have used setpn –X to identify the duplicate SPN. Please refer to following articles and check if help you to solve this issue.
    Event ID 11 — Service Principal
    Name Configuration
    Event ID 11 in the System log of domain controllers
    Please also refer to following article and check if can help you.
    The problem with duplicate SPNs
    Please Note: Since the web site is not hosted by Microsoft, the link may change without notice. Microsoft
    does not guarantee the accuracy of this information.
    If any update, please feel free to let me know.
    Hope this helps.
    Best regards,
    Justin Gu

  • PIVOT sql help

    Hi again
    I need some PIVOT sql help
    In this query:
    SELECT
    SUM([RATES]) as RATES
    ,SUM([CONVERSION])as CONVERSION
    FROM REPORTING
    outputs
    RATES CONVERSION
    23 234
    How would change this query to display a table like:
    Name Amount
    RATES 23
    CONVERSION 234
    Keep up the good work !

    nikos101 wrote:
    > How would change this query to display a table like:
    Do you *HAVE* to change the query... you could just display
    it in the
    desired format if that it the ultimate and only goal.
    <table>
    <tr>
    <td>name</td>
    <td>amount</td>
    </tr>
    <cfoutput query="sumQry">
    <tr><td>Rates</td><td>#rates#</td></tr>
    <tr><td>Conversion</td><td>#conversion#</td></tr>
    </cfoutput>
    </table>

  • Three Nikon Cameras have created duplicate names of files -How do I rename?

    I have loaded hundreds of photos with duplicate names from 3 cameras that use the same naming sequence. How can I at least rename one of the duplicate file names so that I don't have duplicates??????? I appreciate your help.
    -Paul

    Take a look at FileWrangler-it might do what you want.
    Having identical files names is more of a nuisance than a problem these days since the actual files are in different folders.
    Another option: you could try creating keywords like "Nikon 1", "Nikon 2" and "Nikon 3" and batch tagging the images that way.

  • Java.lang.reflect.InvocationTargetException: Duplicate name

    I have a class and demo program that compile. When I try to run them I get the error
    "java.lang.reflect.InvocationTargetException: Duplicate name"
    Can anybody give me an idea of where to start tracking down this problem? I can't see anything that looks duplicated and I can't find any help on this particular issue.
    Thanks,
    Abigail

    I guess I can go ahead an post the code that I do have. This works when compiled and run from the command line.
    Here's my demo program
    import java.util.*;
    import java.lang.*;
    public class FileSortingDemo {
    public static void main(String[] args)
    /* Create an array of FileSorting object */
    int sortOrder = Integer.parseInt(args[0]);
    FileSorting[] files = new FileSorting[3];
    files[0] = new FileSorting(sortOrder,"1.xml",19990101,501);
    files[1] = new FileSorting(sortOrder,"2.xml",19990201,502);
    files[2] = new FileSorting(sortOrder,"0.xml",19990202,499);
    /* Sort array */
    Arrays.sort(files);
    /* Print out sorted values */
    for(int i = 0; i < files.length; i++)
    System.out.println(files.file_name + "     " +
    files[i].file_date + "     " + files[i].file_size);
    //End of Demo Prog
    Here's the class
    import java.util.*;
    public class FileSorting implements Comparable
    public int sort_order;
    public String file_name;
    public long file_date;
    public long file_size;
    public FileSorting(int sort_order, String file_name, long file_date, long file_size)
         this.sort_order = sort_order;
    this.file_name = file_name;
    this.file_date = file_date;
    this.file_size = file_size;
    /* Overload compareTo method */
    public int compareTo(Object obj)
    FileSorting tmp = (FileSorting)obj;
    switch ( tmp.sort_order )
              case 0:
                   if(this.file_name.compareTo(tmp.file_name) < 0)
                   /* instance lt received */
                   return -1;
                   else if(this.file_name.compareTo(tmp.file_name) > 0)
                   /* instance gt received */
                   return 1;
                   /* instance == received */
                   return 0;
              case 1:
                   if(this.file_date < tmp.file_date)
                   /* instance lt received */
                   return -1;
                   else if(this.file_date > tmp.file_date)
                   /* instance gt received */
                   return 1;
                   /* instance == received */
                   return 0;
              case 2:
                   if(this.file_size < tmp.file_size)
                   /* instance lt received */
                   return -1;
                   else if(this.file_size > tmp.file_size)
                   /* instance gt received */
                   return 1;
                   /* instance == received */
                   return 0;
              default:
                   if(this.file_name.compareTo(tmp.file_name) < 0)
                   /* instance lt received */
                   return -1;
                   else if(this.file_name.compareTo(tmp.file_name) > 0)
                   /* instance gt received */
                   return 1;
                   /* instance == received */
                   return 0;

  • LCM Error - Duplicate Name

    Hi,
         I am new to the LCM tool. Whenever I am trying to move my objects(Universes & Reports) from Dev to Quality, the Universes and the connections got successfully moved. But when we move the report it gives an error in the promotion status showing"Promotion Status=Failure : Trying to create an object with duplicate name. Id = 2017 ". Some one in the forum said about this error as CUID. Can anyone explain me what is CUID and how we can rectify this error.
    Thanks & Regards,
    Praveen Kumar

    Hello Denis,
    The following situation has happened on the Business Objects XI 3.1 SP4 with LCM SP4 environments.
    I have set the SNC for both Entitlements, I needed.
    I have set also LCM Job. The result is "Partial success" - please, look at the [screenshot|http://www.edisk.eu/en/download/51788/LCM_mig-result.JPG_158.13KB.html].
    I have followed your advice to [track|http://www.edisk.eu/en/download/06050/QB-2568.JPG_113.25KB.html], what exactly happend for both IDs. The result is [useless|http://www.edisk.eu/en/download/90226/QB-2568-result.JPG_62.13KB.html].
    Can you help me, Where am I supposed to dig?
    Thank you very much.
    Edited by: Ladislav Varga on Nov 12, 2011 11:43 AM
    In addition I have ran another job with checking dependencies of the failsed folders. There are no dependencies. Customer have not provided me the records to the tnsnames.ora... I have realized. So, that is, what I need to check... I hope.

  • Duplicate Name on the network

    Hi, we recently set up BT Broadband in our new home.  (Previously with Sky).
    When I ran the BT installation disk, it said it couldn't see my wireless (very odd), so wouldn't install.  Anyway, so I set up the connection manally and made sure Sky connection info was removed.
    It all connects and works fine.  (Also have Xbox, blu-ray, wii, iphones etc all connecting to BT hub no problems at all).
    However, now when I boot up the laptop it pops up with a warning triangle saying that there is a duplicate name on the network.  Doesn't appear to cause any issues, but it is a bit concerning.  And hasn't appeared in our previous home when we were on Sky.
    Any ideas on how to resolve this?
    Thank you

    try running the ip scanners I pointed you to, not sure how it will react is there is an IP conflict since I don't ever have any but it should show you everything on your network.
    if when you run it it does not show any issues or duplicated then have a look and see if everything you have on the network is actually showing. If not then check the web admin pages (if they have one) for each device not showing and make sure that their network address is not the same as one that is showing.
    At worst you could also try switching everything but router and laptop off totally and then seeing if the message on the laptop goes away
    If my post was helpful then please click on the Ratings star on the left-hand side If the the reply answers your question fully then please select ’Mark as Accepted Solution’

  • Finding duplicate names

    I want to find duplicate names from my database I wrote the following query. But it is displaying more that existing records. I guess it is taking cartesian product.
    select a.name from emp from emp a,emp b where a.name=b.name;
    can anyone correct this query.
    I want to display all the duplicate records having same names...
    for example for the following table. I want to display result having same dname like
    DEPTNO DNAME LOC
    10 ACCOUNTING NEW YORK
    20 RESEARCH DALLAS
    30 SALES CHICAGO
    40 OPERATIONS BOSTON
    50 SALES hyd
    output should be
    30 sales chicago
    50 sales hyd

    Welcome to OTN.
    From your initial sample data - i didn't find anything duplicate. They all are unique if you consider deptno.
    But, i assume you have plenty of redundant data. So, your query may be look like ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.16
    satyaki>
    satyaki>
    satyaki>create table dup_emp
      2     as
      3       select k.*
      4       from (
      5              select * from emp
      6              union all
      7              select * from emp
      8              where rownum < 6
      9            ) k;
    Table created.
    Elapsed: 00:00:03.90
    satyaki>
    satyaki>
    satyaki>select * from dup_emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
    18 rows selected.
    Elapsed: 00:00:00.32
    satyaki>
    satyaki>
    satyaki>select empno, count(empno)
      2  from dup_emp
      3  group by empno
      4  having count(empno) > 1;
         EMPNO COUNT(EMPNO)
          9999            2
          7777            2
          7521            2
          7566            2
          7654            2
    Elapsed: 00:00:00.11
    satyaki>
    satyaki>
    satyaki>Regards.
    Satyaki De.

  • I have copied many photo's from another laptop to my Mac.  The older photo's are in directories with names that help me select what I need to view. I would like to have all my imported new photo's also bee added to the directory structure I have in Finder

    I have copied many photo's from another laptop to my Mac.  The older photo's are in directories with names that help me select what I need to view. I would like to have all my imported new photo's also bee added to the directory structure I have in Finder but my new photo's are all in iPhoto.  I want to use directories for storing and iPhoto for viewing.  Is this possible or do I need to have all my photo's in iPhoto??
    Mitch

    iPhoto is not a Photo Viewer. It's a Photo Manager and designed for looking after the files while you organise the Photos. It really works much better if you let it manage those files. If you use iPhoto you never go near those files because iPhoto is your start point for anything you want to do with your Photos - the point of the pplication.
    You can run iPhoto in Referenced mode, where it does not copy the files to the Library, but I caution you that you are making life a lot more difficult for yourself by doing that.
    How to, and some comments on why you shouldn't, are in this thread
    https://discussions.apple.com/thread/3062728?tstart=0
    Regards
    TD

  • I delete my google contact by fixing the duplicate names, after that I could not add back my contact ? but calendar and e mail works

    I delete my google contact by fixing the duplicate names, after that I could not add back my contact ? but calendar and e mail works

    On my old I phone 3 at the setting it show "mail,contacts, calendars, reminders" but why I phone 4 only show "mail calendar, notes" is this why I can not get my contact back to my phone?

  • Jso.getAnnots() returning duplicate name (key) stamps

    I'm using VBA to parse a document for comments, and storing them in a dictionary object. I ran into an issue where jso.getAnnots is returning a duplicate name for an item.
    Looking into the issue, there are comments with the same text that don't cause this issue.
    Looking for a fix and the cause of this issue.
    Why would it generate an identical name for a different comment? We've run hundreds of documents with this before and this issue has never occurred before. The name seems to be a unique key, such as "820edea8-c848-432a-aadd-987316a9ea7f".
    Here's a snippet of the code:
         jso.syncAnnotScan()
          Annots = jso.getAnnots()
          ' Pass one - get all the comments.
    Dim Annots As Object
          Dim Annot As Object
          Dim acroAnnotation As Annotation
          Dim childAnnotation As Annotation
          Dim annotationSet As New Dictionary(Of String, Annotation)
          Dim rootAnnotations As New Dictionary(Of String, Annotation)
            For Each Annot In Annots
                    acroAnnotation = New Annotation(Annot, FromFilename)
                    annotationSet.Add(Annot.name, acroAnnotation)
                    If Annot.inReplyTo = "" Then
                        rootAnnotations.Add(Annot.name, acroAnnotation)
                    End If
            Next Annot
    It crashes at annotationSet.Add(Annot.name,acroAnnotation)

    Ok I managed to get 4.3.1 working in the end. It turned out that because I was using Skinny Wars in maven, it has unforseen side effects with the ChangeAwareClassLoader. I thought I tried this problem without using Skinny Wars, but I guess I didn't.
    Edited by: 1002618 on May 1, 2013 9:57 PM

  • Want to get totaly how many is insert and how the duplicate name

    Hi all,
    I need to insert a group of string into database it work, but I also need to know how many rows is insert, and out put the duplicat name out
    My code is
    while(tokens.hasMoreTokens()) {
    MySec=tokens.nextToken();
    while(token.hasMoreTokens()) {
    rs = stmt.executeQuery("select * FROM "+table+" where Name='"+Name+"' and Segment='"+Segment+"'");
    // same sequences will only allow to upload once.
    int Row=0;
    while(rs.next()) {
    Row ++; // count rows in record.
    connectionPool.returnConnection(conn);
    if(Row <1){
    conn.setAutoCommit(false);
    //insert data into different tables
    stmt.executeUpdate("insert into "+table+" ("
    + "Name, Segment, Sequence, SubType,location, SampleYear, author)"
    + "VALUES('"
    + Name + "','"
    + Segment+ "','"
    + word+ "','"
    + subType + "','"
    + loc + "','"
    + year+ "','"
    + author + "'"
    + ")");
    conn.commit();
    conn.setAutoCommit(true);}//end if
    else{
    dupli[k]=Name;
    k++;}
    }//in while
    }out while
    Thank you

    Orange file?!?I.e. not the Apple file.

Maybe you are looking for